What is $errno in set
set_error_handler callback function accepts 2 mandatory arguments and 3 optional arguments. One of which is $errno (first one).
What is its use ? Is it integer representation of E_ALL or E_NOTICE .... ?
The $errno contains the level of the error raised, as an integer.
I think this example will make it clear (not my code):
switch ($errno) {
case E_USER_ERROR:
echo "<b>My ERROR</b> [$errno] $errstr<br />n";
echo " Fatal error on line $errline in file $errfile";
echo ", PHP " . PHP_VERSION . " (" . PHP_OS . ")<br />n";
echo "Aborting...<br />n";
exit(1);
break;
case E_USER_WARNING:
echo "<b>My WARNING</b> [$errno] $errstr<br />n";
break;
case E_USER_NOTICE:
echo "<b>My NOTICE</b> [$errno] $errstr<br />n";
break;
default:
echo "Unknown error type: [$errno] $errstr<br />n";
break;
}
From the docs for set_error_handler()
regarding the error handler:
The first parameter, errno , contains the level of the error raised, as an integer.
It will be one of the predefined error constants, eg E_USER_WARNING
, E_NOTICE
, etc.
上一篇: .htaccess设置错误
下一篇: 什么是$ errno集合