note 32952 deleted from function.eval by vincent

From: Date: Mon, 08 Sep 2003 14:29:17 +0000
Subject: note 32952 deleted from function.eval by vincent
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-55800@lists.php.net to get a copy of this message
Note Submitter: gk@proliberty.com ---- eval() returns FALSE if a fatal error occurs. For this reason, you should never return() a FALSE value from eval()'d code or else you will lose the distinction between FALSE and FATAL. Note also that if you have installed a custom error handler, with set_error_handler(), it will NOT be used to handle errors inside your eval() statement. You can call eval("set_error_handler('myErrorHandler'); //...") but Parse and other Fatal errors that NEVER are passed to a custom error handler will still always result in FALSE being returned from eval(). Sample code: <?php // FILE: test/test.php $x=eval(";"); echo "Default Return Value: "; if($x===FALSE) echo "FALSE\n"; if(is_null($x)) echo "NULL\n"; $x=eval("<?"); echo "Fatal Error Returns: "; if($x===FALSE) echo "FALSE\n"; if(is_null($x)) echo "NULL\n"; ?> OUTPUT: $ php test/test.php Default Return Value: NULL PHP Parse error: parse error in /usr/local/apache/htdocs/common/php/xmake_org/xobj/test/test.php(6) : eval()'d code on line 1 Fatal Error Returns: FALSE

« previous php.notes (#55800) next »