note 99889 deleted from function.eval by danbrown
| From: | danbrown@php.net | Date: | Mon, 13 Sep 2010 15:08:19 +0000 |
| Subject: | note 99889 deleted from function.eval by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-172514@lists.php.net to get a copy of this message | ||
Note Submitter: php at rijkvanwel dot nl
----
To catch a parse error in eval()'ed code with a custom error handler, use error_get_last() (PHP
>= 5.2.0).
<?php
$return = eval( 'parse error' );
if ( $return === false ) {
if ( $error = error_get_last() ) {
myErrorHandler( $error['type'], $error['message'], $error['file'],
$error['line'], null );
// Since the "execution of the following code continues normally", as stated in the
manual,
// we still have to exit explicitly in case of an error
exit;
}
}
?>