|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[1999-12-13 15:46 UTC] joey at cvs dot php dot net
[2000-07-18 10:32 UTC] hholzgra at cvs dot php dot net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Oct 25 10:00:01 2025 UTC |
<% $ONE = "one"; $TWO = "TWO"; function test () { $f = array ('ONE', 'TWO'); for ($i = 0; $i < count ($f); ++$i) { GLOBAL ${$f[$i]}; // this line produces parse err // GLOBAL $$f[$i]; // parses OK and is OK. print "<p>" . ${$f[$i]} . "\n"; } } test (); %> May be a documentation error. Cf. http://www.php3.de/manual/variable-variable.php3 "In order to use variable variables with arrays, you have to resolve an ambiguity problem. That is, if you write $$a[1] then the parser needs to know if you meant to use $a[1] as a variable, or if you wanted $$a as the variable and then the [1] index from that variable. The syntax for resolving this ambiguity is: ${$a[1]} for the first case and ${$a}[1] for the second"