Bug #15241: eval() is not allow evaluating code from constants
| From: | flying at dom dot natm dot ru | Date: | Sun, 27 Jan 2002 11:46:33 +0000 |
| Subject: | Bug #15241: eval() is not allow evaluating code from constants | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-78244@lists.php.net to get a copy of this message | ||
From: flying@dom.natm.ru
Operating system: all
PHP version: 4.1.1
PHP Bug Type: Scripting Engine problem
Bug description: eval() is not allow evaluating code from constants
Check out these simple examples:
Example 1:
-----------------------------------------------------
<?php
function getCode()
{
return("echo 'hello world!';");
};
eval(getCode());
?>
-----------------------------------------------------
Result of executing whis example will be a string 'hello world!' as
expected.
Example 2:
-----------------------------------------------------
<?php
define('PHP_CODE','getCode()');
function getCode()
{
return("echo 'hello world!';");
};
eval(PHP_CODE);
?>
-----------------------------------------------------
As you can see - i just move code from eval() into constant
and substitute it with constant name instead of actual code into eval()
statement.
But result of executing this example is:
Parse error: parse error in test.php(9) : eval()'d code on line 1
Tested with both 4.0.6 and 4.1.1 on windows 2000 and linux.
--
Edit bug report at: http://bugs.php.net/?id=15241&edit=1