Created
November 21, 2013 09:53
-
-
Save bolstad/7578888 to your computer and use it in GitHub Desktop.
strict error reporting for 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
error_reporting( E_ALL ); | |
ini_set( 'display_errors', 'On' ); | |
ini_set( 'display_startup_errors', 'On' ); | |
// error report routine based on code by pekka @ stackowerflow http://stackoverflow.com/a/3193084 | |
error_reporting( -1 ); | |
function terminate_missing_variables( $errno, $errstr, $errfile, $errline ) { | |
if ( ( $errno == E_NOTICE ) and ( strstr( $errstr, "Undefined variable" ) || strstr( $errstr, "Undefined property" ) || strstr( $errstr, "Undefined index" ) ) ) | |
die ( "\nFATAL: $errstr in $errfile line $errline \n" ); | |
return false; // Let the PHP error handler handle all the rest | |
} | |
$old_error_handler = set_error_handler( "terminate_missing_variables" ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment