Bug #993: GLOBAL ${$x[$i]} gives parse error

From: Date: Thu, 17 Dec 1998 09:51:34 +0000
Subject: Bug #993: GLOBAL ${$x[$i]} gives parse error
Groups: php.dev 
Request: Send a blank email to php-dev+get-2820@lists.php.net to get a copy of this message
From: vogtner@soldan.de Operating system: Solaris 2.5.1 PHP version: 3.0.5 PHP Bug Type: Parser error Bug description: GLOBAL ${$x[$i]} gives parse error <% $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" -- PHP Development Mailing List http://www.php.net/ To unsubscribe send an empty message to php-dev-unsubscribe@lists.php.net For help: php-dev-help@lists.php.net

« previous php.dev (#2820) next »