How can I display (echo/print) the currently set error reporting level in PHP? How can I display (echo/print) the currently set error reporting level in PHP? php php

How can I display (echo/print) the currently set error reporting level in PHP?


http://www.php.net/error_reporting

int error_reporting ([ int $level ] )

Returns the old error_reporting level or the current level if no level parameter is given.

You could also use examples provided by the link in order to cast the level (which is returned as integer) into the string. For example:

function error_level_tostring($intval, $separator = ','){    $errorlevels = array(        E_ALL => 'E_ALL',        E_USER_DEPRECATED => 'E_USER_DEPRECATED',        E_DEPRECATED => 'E_DEPRECATED',        E_RECOVERABLE_ERROR => 'E_RECOVERABLE_ERROR',        E_STRICT => 'E_STRICT',        E_USER_NOTICE => 'E_USER_NOTICE',        E_USER_WARNING => 'E_USER_WARNING',        E_USER_ERROR => 'E_USER_ERROR',        E_COMPILE_WARNING => 'E_COMPILE_WARNING',        E_COMPILE_ERROR => 'E_COMPILE_ERROR',        E_CORE_WARNING => 'E_CORE_WARNING',        E_CORE_ERROR => 'E_CORE_ERROR',        E_NOTICE => 'E_NOTICE',        E_PARSE => 'E_PARSE',        E_WARNING => 'E_WARNING',        E_ERROR => 'E_ERROR');    $result = '';    foreach($errorlevels as $number => $name)    {        if (($intval & $number) == $number) {            $result .= ($result != '' ? $separator : '').$name; }    }    return $result;}

use it as echo error_level_tostring(error_reporting(), ',');


Use error_reporting() with no parameters. It will return the current error level.

http://php.net/manual/en/function.error-reporting.php