Created
January 9, 2013 03:29
-
-
Save brianr/4490325 to your computer and use it in GitHub Desktop.
PHP - detect parse errors via shutdown handler
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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'); | |
?> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$foo =; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment