Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/github/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php set_error_处理程序是否捕获未包含在error_reporting()中的错误_Php - Fatal编程技术网

Php set_error_处理程序是否捕获未包含在error_reporting()中的错误

Php set_error_处理程序是否捕获未包含在error_reporting()中的错误,php,Php,如果我从error\u reporting()-error\u reporting(E\u ALL&~E\u WARNING)中排除E\u WARNING错误,是否会为PHP警告错误调用我在set\u error\u handler('error\u handler')中注册的自定义错误处理程序 我这样问是因为Kohana框架中有以下代码: public static function error_handler($code, $error, $file = NULL, $line = NULL

如果我从
error\u reporting()
-
error\u reporting(E\u ALL&~E\u WARNING)
中排除
E\u WARNING
错误,是否会为PHP警告错误调用我在
set\u error\u handler('error\u handler')
中注册的自定义错误处理程序

我这样问是因为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\u reporting()&$code)
,而我希望函数
error\u handler
永远不会被触发,因为不应该被处理的错误。

我想我自己已经找到了答案(来自:

重要的是要记住,除非回调函数返回FALSE,否则对于error_type指定的错误类型,标准PHP错误处理程序将被完全绕过。error_reporting()设置将不起作用,您的错误处理程序将被调用,但您仍然能够读取error_reporting()的当前值并采取适当的行动。需要特别注意的是,如果引起错误的语句是由@error control运算符预先指定的,则该值将为0。

error\u reporting()设置将不起作用,并且将调用您的错误处理程序