RE: Bug #11962 Updated: eval() doesn't handle multi-dimentional arrays.

From: Date: Mon, 09 Jul 2001 12:02:00 +0000
Subject: RE: Bug #11962 Updated: eval() doesn't handle multi-dimentional arrays.
References: 1 2  Groups: php.dev php.dev 
Request: Send a blank email to php-dev+get-59269@lists.php.net to get a copy of this message
It's all in the manual. http://www.php.net/manual/en/language.types.string.php For parsing variables (and arrays) in strings, and also why it works with only one array-index. http://www.php.net/manual/en/language.types.array.php For how to access arrays (even variable ones). Jeroen On Mon, 9 Jul 2001, Karl Austin wrote: > OK, so how come it works with 1 dimensional arrays? Surely it would make > sense to make it work with multi-dimensional arrays or not with arrays full > stop? > > Karl Austin > > -----Original Message----- > From: Bug Database [mailto:php-dev@lists.php.net] > Sent: 09 July 2001 12:09 > To: karl@kdawebservices.com > Subject: Bug #11962 Updated: eval() doesn't handle multi-dimentional > arrays. > > > ID: 11962 > Updated by: jeroen > Reported By: karl@kdawebservices.com > Old Summary: eval() doesn't handle multi-dimentional arrays. > Old Status: Open > Status: Bogus > Bug Type: Scripting Engine problem > Operating System: RedHat 6.2 > PHP Version: 4.0.6 > New Comment: > > Your string equals 'echo "$GLOBALS[page][title]";', and RTFM why that > doesn't work. > > Previous Comments: > ------------------------------------------------------------------------ > > [2001-07-08 20:00:57] karl@kdawebservices.com > > It appears that eval() does not handle mutli-dimentional arrays properly > e.g. $page[title] = 'Page'; $test = '$page[title]'; If I do: eval( > 'echo > "'.$test.'";' ); I get: Page as the output, however if I change > $test to: > $test = '$GLOBALS[page][title]'; then do: eval( 'echo > "'.$test.'";' ); I > get: Array[title] as my output. My best guess for the reason this is > happening is that when eval() does a lookup for a variable in the symbol > table it is going from top to bottom and stops on the first match, no matter > how complete - From this I am assuming that the symbol table would be built > as follows: $GLOBALS $GLOBALS[page] $GLOBALS[page][title] so if eval() > searched from the top then it would find a partial match against > $GLOBALS[page] which is what I think it is doing. A better example: > $page[title] = 'Hello'; $string = '$page[title]'; eval( 'echo > "'.$string.'";' ); echo "<br>\n"; $string = > '$GLOBALS[page][title]'; eval( 'echo > "'.$string.'";' ); I hope I make > sense to you, if not then please let me know and I will try and be clearer. > > ------------------------------------------------------------------------ > > > > ATTENTION! Do NOT reply to this email! > To reply, use the web interface found at > http://bugs.php.net/?id=11962&edit=1 > > > > Jeroen van Wolffelaar Jeroen@A-Eskwadraat.nl http://www.A-Eskwadraat.nl/~jeroen

« previous php.dev (#59269) next »