Skip to content

Instantly share code, notes, and snippets.

@CDRO
Created July 7, 2017 09:56
Show Gist options
  • Save CDRO/6fbadef1f74c051792d58213d6043745 to your computer and use it in GitHub Desktop.
Save CDRO/6fbadef1f74c051792d58213d6043745 to your computer and use it in GitHub Desktop.
<?php
/**
* Usage:
* php ./calculate_set_error_reporting.php *somecode*
*/
if($_SERVER['argc'] > 1) {
$errorCode = intval($_SERVER['argv'][1]);
} else {
die('Please give me an error code');
}
$errors = [
'E_ERROR' => E_ERROR,
'E_WARNING' => E_WARNING,
'E_PARSE' => E_PARSE,
'E_NOTICE' => E_NOTICE,
'E_CORE_ERROR' => E_CORE_ERROR,
'E_CORE_WARNING' => E_CORE_WARNING,
'E_COMPILE_ERROR' => E_COMPILE_ERROR,
'E_COMPILE_WARNING' => E_COMPILE_WARNING,
'E_USER_ERROR' => E_USER_ERROR,
'E_USER_WARNING' => E_USER_WARNING,
'E_USER_NOTICE' => E_USER_NOTICE,
'E_STRICT' => E_STRICT,
'E_RECOVERABLE_ERROR' => E_RECOVERABLE_ERROR,
'E_DEPRECATED' => E_DEPRECATED,
'E_USER_DEPRECATED' => E_USER_DEPRECATED,
];
echo 'Set flags:' . PHP_EOL;
foreach($errors as $name => $error) {
//echo $error & $errorCode;
if($errorCode & $error) {
echo $name . PHP_EOL;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment