set_error_handler() and fatal errors?

From: Date: Wed, 13 Dec 2000 18:39:55 +0000
Subject: set_error_handler() and fatal errors?
Groups: php.dev 
Request: Send a blank email to php-dev+get-41201@lists.php.net to get a copy of this message
I think set_error_handler() should be able to catch fatal errors as well as the non-fatal ones if possible. The current documentation indicates that fatal errors can be caught, but it doesn't actually work. This script for example: <? error_reporting(E_ERROR|E_WARNING|E_PARSE|E_NOTICE|E_CORE_ERROR|E_CORE_WARNING|E_COMPILE_ERROR|E_COMPILE_WARNING|E_USER_ERROR|E_USER_WARNING|E_USER_NOTICE); function myHandler($errno, $errstr, $errfile, $errline) { echo "$errno: $errstr on line $errline in $errfile\n"; } set_error_handler("myHandler"); echo $a; blah(); ?> Gives me: 8: Undefined variable: a on line 9 in t <br> <b>Fatal error</b>: Call to undefined function: blah() in <b>t</b> on line <b>10</b><br> which shows that MyHandler() was only called for the undefined variable problem. If we can't catch fatal errors for some reason we need to reflect this in the documentation. Looking at the code I don't see any real reason not to be able to catch fatal errors. -Rasmus

« previous php.dev (#41201) next »