开发者

${'varname_'.$x} variable in PHP [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.

Want to improve this question? Add details and clarify the problem by editing this post.

Closed 9 years ago.

Improve this question 开发者_运维百科

Can someone please remind me how you call this type of variable

${'varname_'.$x}

Thanks!


It's called variable variables!


This should do it:

$varname = 'varname_'.$x;
echo $$varname;


variable varibales!!!

$var = "varname$x";
for($x=0;$x<10;$x++)
{
    echo $$var;
}

edit ====

SHOULD BE:

for($x=0;$x<10;$x++)
{
    $var = "varname$x";
    echo $$var;
}


Variable variables. Your example could be used like so:

$varname_0 = 'Hello World!';
$x = 0;
echo ${'varname_'.$x}; // 'Hello World!'
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜