note 35603 deleted from function.eval by vincent

From: Date: Mon, 08 Sep 2003 14:29:20 +0000
Subject: note 35603 deleted from function.eval by vincent
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-55801@lists.php.net to get a copy of this message
Note Submitter: skissane@ics.mq.edu.au ---- Contrary to the note below, a parse error results in eval() returning FALSE, but a fatal error results in a fatal error in the calling code as well, and hence eval() never returning anything. (Tested under PHP 4.3.3) ==== Example #1 === <?php // FILE: test.php ob_start(); $x = eval("-+;-+-+;"); $msg = ob_get_contents(); ob_end_clean(); echo "Got return value: " . ($x === FALSE ? "FALSE" : "unexpected return value!") . "<br>\n"; echo "Got error message: <tt>" . htmlspecialchars($msg) . "</tt><br>\n"; ?> Output: Got return value: FALSE Got error message: <br /> <b>Parse error</b>: parse error in <b>test.php(3) : eval()'d code</b> on line <b>1</b><br /> ==== Example #2 ==== <?php // FILE: test.php ob_start(); $x = eval("-+;-+-+;"); $msg = ob_get_contents(); ob_end_clean(); echo "Got return value: " . ($x === FALSE ? "FALSE" : "unexpected return value!") . "<br>\n"; echo "Got error message: <tt>" . htmlspecialchars($msg) . "</tt><br>\n"; ?> Output: Fatal error: Call to undefined function: nonexistentfunction() in test.php(3) : eval()'d code on line 1

« previous php.notes (#55801) next »