Skip to content

Instantly share code, notes, and snippets.

@bolstad
Created November 21, 2013 09:53
Show Gist options
  • Save bolstad/7578888 to your computer and use it in GitHub Desktop.
Save bolstad/7578888 to your computer and use it in GitHub Desktop.
strict error reporting for PHP
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