#27101 [Bgs]: Eval Error

From: Date: Fri, 30 Jan 2004 22:36:17 +0000
Subject: #27101 [Bgs]: Eval Error
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-54200@lists.php.net to get a copy of this message
ID: 27101 Updated by: derick@php.net Reported By: daniel dot marschall at surfeu dot de Status: Bogus Bug Type: *Programming Data Structures Operating System: Linux PHP Version: 4.3.4 New Comment: oops, tom is right Previous Comments: ------------------------------------------------------------------------ [2004-01-30 17:36:16] daniel dot marschall at surfeu dot de Hello. I was wrong. My real problem is: # taken from a user comment function eval_buffer($string) { ob_start(); eval("$string[2];"); $return = ob_get_contents(); ob_end_clean(); return $return; } function eval_print_buffer($string) { ob_start(); eval("print $string[2];"); $return = ob_get_contents(); ob_end_clean(); return $return; } function eval_html($string) { $string = preg_replace_callback("/(<\?=)(.*?)\?>/si", "eval_print_buffer",$string); return preg_replace_callback("/(<\?php|<\?)(.*?)\?>/si", "eval_buffer",$string); } echo html_eval('<? if (1 == 1) { ?><? } ?>'); And this causes the error. But I don't know if it is the fault of the user-comment-script or if the problem is in eval. ------------------------------------------------------------------------ [2004-01-30 17:35:50] derick@php.net Not enough information was provided for us to be able to handle this bug. Please re-read the instructions at http://bugs.php.net/how-to-report.php If you can provide more information, feel free to add it to this bug and change the status back to "Open". Thank you for your interest in PHP. ------------------------------------------------------------------------ [2004-01-30 17:29:56] tomsommer@php.net 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 You can't have nested php-tags, try: eval('if (1 == 1) { ?>works<? }'); in a sense your example does: <?php <? if (1 == 1) { ?><? } ?> ?> Which is wrong ------------------------------------------------------------------------ [2004-01-30 17:13:13] daniel dot marschall at surfeu dot de Description: ------------ <?php echo eval('<? if (1 == 1) { ?><? } ?>'); ?> This let a parse error in the eval appear. The Code <? if (1 == 1) { ?><? } ?> is ok and don't let the parse error appear. ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=27101&edit=1

« previous php.bugs (#54200) next »