开发者

variable in variable in php

$var="profile['Gamer']['last_name']";
ec开发者_高级运维ho ${$var};

Gives

Undefined variable: profile['Gamer']['last_name']

. But if i try to echo $profile['Gamer']['last_name'] value exist

I have tried echo $$var that too didn't work


There is no variable profile['Gamer']['last_name']. There is only a variable named profile.

$var = "profile";
echo ${$var}['Gamer']['last_name'];


$var="profile['Gamer']['last_name']";
eval('$result = $' . $var . ';');
echo $result;

Keep in mind that there are serious security issues to something like this, and that your code will probably be very hard to understand for anybody but your self.


try this:

$var="profile['Gamer']['last_name']";
eval("echo $".$var.";");
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜