Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
set_exception_handler(function ($e) {
echo 'Got it: ' . $e->getMessage() . "\n";
register_shutdown_function(function () {
throw new \Exception('This one will cause Fatal error');
throw new \Exception('Will be caught by exception handler');
Copy link

Yrwein commented Apr 4, 2018

Got it: Will be caught by exception handler
PHP Fatal error: Uncaught Exception: This one will cause Fatal error in /home/josef/work/src/shutdown.php:8
Stack trace:
#0 [internal function]: {closure}()
#1 {main}
thrown in /home/josef/work/src/shutdown.php on line 8

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment