note 35603 added to function.eval
| From: | skissane at ics dot mq dot edu dot au | Date: | Mon, 08 Sep 2003 07:17:27 +0000 |
| Subject: | note 35603 added to function.eval | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-55776@lists.php.net to get a copy of this message | ||
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
----
Manual Page -- http://www.php.net/manual/en/function.eval.php
Edit Note -- http://master.php.net/manage/user-notes.php?action=edit+35603
Delete Note -- http://master.php.net/manage/user-notes.php?action=delete+35603&report=yes
Reject Note -- http://master.php.net/manage/user-notes.php?action=reject+35603&report=yes