Skip to content

Instantly share code, notes, and snippets.

@stubbetje
Created July 8, 2011 14:14
Show Gist options
  • Save stubbetje/1071930 to your computer and use it in GitHub Desktop.
Save stubbetje/1071930 to your computer and use it in GitHub Desktop.
Show what error levels are included in a given error_reporting() value
<?php
if( $_SERVER['argc'] === 1 ) {
printf(
'No error level specified as argument (%s <errorlevel>), using current error_reporting value...' . PHP_EOL
, $_SERVER['argv'][0]
);
$errorlevel = error_reporting();
} else {
$errorlevel = (int) $_SERVER['argv'][1];
}
$constants = get_defined_constants(true);
// add some custom error constants
$constants['Core']['E_ALL | E_STRICT'] = E_ALL | E_STRICT;
foreach( $constants['Core'] as $name => $value ) {
if( strpos($name , 'E_' ) === 0 ) {
if( ( $errorlevel & $value ) === $value ) {
printf( '%5d → %s' . PHP_EOL , $value , $name );
}
}
}
//printf( '%5d → E_ALL | E_STRICT' . PHP_EOL , E_ALL | E_STRICT );
printf( '-------------------------------' . PHP_EOL );
printf( '%5d → current error level' . PHP_EOL , $errorlevel );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment