I am working on a rather large project (multiple teams) so I don't have complete control over the code. Unfortunately, error_reporting is changed in many places throughout the code. When I get to a certain point in the code, I want to see what error reporting is currently set to. Is there anyway to accomplish this?
Quickly Show All PHP Errors The quickest way to display all php errors and warnings is to add these lines to your PHP code file: ini_set('display_errors', 1); ini_set('display_startup_errors', 1); error_reporting(E_ALL);
error_reporting: It displays all level errors except E-NOTICE, E-STRICT, and E_DEPRECATED level errors. display_errors: By default, the value of display_errors is off.
How many error levels are available in PHP? There are a whopping 16 error levels in PHP 5. These errors represent the category and sometimes severity of an error 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(), ',');
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With