From:             [EMAIL PROTECTED]
Operating system: RedHat 6.2
PHP version:      4.0.6
PHP Bug Type:     Scripting Engine problem
Bug description:  eval() doesn't handle multi-dimentional arrays.

It appears that eval() does not handle mutli-dimentional arrays properly

$page[title] = 'Page';
$test = '$page[title]';

If I do:

eval( 'echo "'.$test.'";' );

I get:


as the output, however if I change $test to:

$test = '$GLOBALS[page][title]';

then do:

eval( 'echo "'.$test.'";' );

I get:


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:


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.
Edit bug report at:

PHP Development Mailing List <>
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to