#15241 [Ana->Bgs]: eval() is not allow evaluating code from constants

From: Date: Wed, 31 Jul 2002 13:25:44 +0000
Subject: #15241 [Ana->Bgs]: eval() is not allow evaluating code from constants
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-15668@lists.php.net to get a copy of this message
ID: 15241 Updated by: iliaa@php.net Reported By: flying@dom.natm.ru -Status: Analyzed +Status: Bogus Bug Type: Scripting Engine problem Operating System: all PHP Version: 4.1.1 Assigned To: hholzgra New Comment: Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation available at http://www.php.net/manual/ and the instructions on how to report a bug at http://bugs.php.net/how-to-report.php if you add a ; to the define('PHP_CODE','getCode()'); so it looks like this: define('PHP_CODE','getCode();'); the parse error will go away. You are also trying to do a double eval, which is imposible to do. Previous Comments: ------------------------------------------------------------------------ [2002-06-17 17:01:08] hholzgra@php.net yet another locale dependant ZE bug only affecting non-latin locales (like cyrillic) for now either use lowercase constants or setlocale(LC_ALL, "C") ------------------------------------------------------------------------ [2002-01-27 06:46:32] flying@dom.natm.ru 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 this bug report at http://bugs.php.net/?id=15241&edit=1

« previous php.bugs (#15668) next »