如果我从E_WARNING
- error_reporting()
中排除error_reporting(E_ALL & ~E_WARNING)
错误,我的自定义错误处理程序是否会因为set_error_handler('error_handler')
而调用PHP警告错误?
我问这个是因为Kohana框架中有以下代码:
public static function error_handler($code, $error, $file = NULL, $line = NULL)
{
if (error_reporting() & $code)
{
// This error is not suppressed by current error reporting settings
// Convert the error into an ErrorException
throw new ErrorException($error, $code, 0, $file, $line);
}
// Do not execute the PHP error handler
return TRUE;
}
检查是否应该处理触发函数if (error_reporting() & $code)
,而我希望函数error_hanlder
永远不会因不应该处理的错误而被触发。
答案 0 :(得分:0)
我想我自己找到了答案(来自here):
It is important to remember that the standard PHP error handler is completely bypassed for the error types specified by error_types unless the callback function returns FALSE. error_reporting() settings will have no effect and your error handler will be called regardless - however you are still able to read the current value of error_reporting and act appropriately. Of particular note is that this value will be 0 if the statement that caused the error was prepended by the @ error-control operator.
error_reporting()设置无效,无论
,都会调用错误处理程序