note 82864 added to language.types.array
| From: | fmouse at fmp dot com | Date: | Tue, 29 Apr 2008 20:14:27 +0000 |
| Subject: | note 82864 added to language.types.array | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-138914@lists.php.net to get a copy of this message | ||
Using variables as array names no longer works in PHP5.
$fum = "somevar";
$foo = $$fum;
# Still works if $somevar isn't an array. $foo contains the value of $somevar
but ....
$fum = "_POST";
print_r($$fum);
print_r(${$fum});
Neither form of indirection works in this context. $$fum comes back empty.
If you have PHP4 code that used this kind of indirection you can work around the change in PHP5
using an eval().
$fum = "_POST";
$foo = eval("return $$fum;");
print_r($foo);
This works!
----
Server IP: 64.71.164.2
Probable Submitter: 70.112.242.197
----
Manual Page -- http://www.php.net/manual/en/language.types.array.php
Edit -- https://master.php.net/note/edit/82864
Del: integrated -- https://master.php.net/note/delete/82864/integrated
Del: useless -- https://master.php.net/note/delete/82864/useless
Del: bad code -- https://master.php.net/note/delete/82864/bad+code
Del: spam -- https://master.php.net/note/delete/82864/spam
Del: non-english -- https://master.php.net/note/delete/82864/non-english
Del: in docs -- https://master.php.net/note/delete/82864/in+docs
Del: other reasons-- https://master.php.net/note/delete/82864
Reject -- https://master.php.net/note/reject/82864
Search -- https://master.php.net/manage/user-notes.php