Skip to content

Instantly share code, notes, and snippets.

@JonatanFlores
Forked from rcmachado/error_reporting.php
Created November 16, 2016 12:30
Show Gist options
  • Save JonatanFlores/4bf9aee7b320884711a02787f3d9d458 to your computer and use it in GitHub Desktop.
Save JonatanFlores/4bf9aee7b320884711a02787f3d9d458 to your computer and use it in GitHub Desktop.
Script to verify PHP error_reporting settings. Adapted from http://us3.php.net/manual/en/errorfunc.constants.php#109430
<?php
$errorLevel = error_reporting();
print "Current error_reporting level: $errorLevel <br>\n";
print "E_ALL value: " . E_ALL . " <br>\n";
for ($i = 0; $i < 15; $i++) {
$errVal = $errLevel & pow(2, $i);
print FriendlyErrorType($errVal) . " ($errVal) <br>\n";
}
function FriendlyErrorType($type)
{
switch($type)
{
case E_ERROR: // 1
return 'E_ERROR';
case E_WARNING: // 2
return 'E_WARNING';
case E_PARSE: // 4
return 'E_PARSE';
case E_NOTICE: // 8
return 'E_NOTICE';
case E_CORE_ERROR: // 16
return 'E_CORE_ERROR';
case E_CORE_WARNING: // 32
return 'E_CORE_WARNING';
case E_COMPILE_ERROR: // 64
return 'E_COMPILE_ERROR';
case E_COMPILE_WARNING: // 128
return 'E_COMPILE_WARNING';
case E_USER_ERROR: // 256
return 'E_USER_ERROR';
case E_USER_WARNING: // 512
return 'E_USER_WARNING';
case E_USER_NOTICE: // 1024
return 'E_USER_NOTICE';
case E_STRICT: // 2048
return 'E_STRICT';
case E_RECOVERABLE_ERROR: // 4096
return 'E_RECOVERABLE_ERROR';
case E_DEPRECATED: // 8192
return 'E_DEPRECATED';
case E_USER_DEPRECATED: // 16384
return 'E_USER_DEPRECATED';
}
return "";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment