Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save Yrwein/305d07f47a5f16a98fa2920aa85a8243 to your computer and use it in GitHub Desktop.
Save Yrwein/305d07f47a5f16a98fa2920aa85a8243 to your computer and use it in GitHub Desktop.
<?php
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');
@Yrwein
Copy link
Author

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