note 94388 deleted from function.set-error-handler by danbrown

From: Date: Mon, 02 Nov 2009 15:29:13 +0000
Subject: note 94388 deleted from function.set-error-handler by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-162333@lists.php.net to get a copy of this message
Note Submitter: andy at groupspaces dotcom ---- I just discovered it’s possible to catch fatal E_ERROR errors and direct them to your custom error handler using a combination of register_shutdown_function() and error_get_last(): <?php set_error_handler('myErrorHandler'); register_shutdown_handler('fatalErrorShutdownHandler'); function myErrorHandler($code, $message, $file, $line) { ... } function fatalErrorShutdownHandler() { $last_error = error_get_last(); if ($last_error['type'] === E_ERROR) { // fatal error myErrorHandler(E_ERROR, $last_error['message'], $last_error['file'], $last_error['line']); } } ?> See also my post (doesn't say much more than the above): http://insomanic.me.uk/post/229851073/php-trick-catching-fatal-errors

« previous php.notes (#162333) next »