Skip to content

Instantly share code, notes, and snippets.

@brianr
Created January 9, 2013 03:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brianr/4490325 to your computer and use it in GitHub Desktop.
Save brianr/4490325 to your computer and use it in GitHub Desktop.
PHP - detect parse errors via shutdown handler
Brian-Rues-MacBook-Pro:test brian$ php parse_error_1.php
Parse error: parse error in /Users/brian/www/ratchetio-php/test/parse_error_2.php on line 2
in shutdown handler
last error:
array(4) {
["type"]=>
int(4)
["message"]=>
string(11) "parse error"
["file"]=>
string(53) "/Users/brian/www/ratchetio-php/test/parse_error_2.php"
["line"]=>
int(2)
}
<?php
function on_shutdown() {
echo "in shutdown handler\n";
$last_error = error_get_last();
echo "last error:\n";
var_dump($last_error);
}
register_shutdown_function(on_shutdown);
require('parse_error_2.php');
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment