php - 为什么set_error_handler不排除不是error_types的错误?

标签 php error-handling

这是我的定义:

set_error_handler('errorHandler', E_ALL ^ E_NOTICE ^ E_STRICT ^ E_DEPRECATED);

因此,从本质上讲,我给set_error_handler的值为22519,其中不包括上述错误类型。但是,我的errorHandler函数仍然收到严格的错误。我尚未通过通知对其进行测试。我的功能很基本:
function errorHandler($number, $string, $file, $line) {
    $message = "$number: $string in $file on line $line";
    throw new \Exception($message, $number);
}

我得到的东西是:
Exception 2048 2048: Declaration of X should be compatible with that of Y in XF on line 19 in ErrorHandler.php on line 70

如您所知,我希望所有PHP错误都抛出一个异常,以便于调试。

最佳答案

通过Googling E_ALLE_STRICT,我发现E_STRICT在PHP 5.4.0中成为E_ALL的一部分,但是我的服务器是PHP 5.3.0。这解释了差异。

关于php - 为什么set_error_handler不排除不是error_types的错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22546832/

相关文章:

c++ - Xerces:如何使用 ErrorHandler 检查 XML 文件的有效性

error-handling - ServiceStack-如何从RequestFilter返回ResponseDTO?

php - 如何在 prestashop 网络服务中获取图像 ID

python - 为什么我的try-exception-final无法正常工作

python - 为什么在没有Except block 的情况下Python仍会引发异常?

javascript - 在promise内部出错后继续子循环-try/catch

PHP我如何将参数传递给常量

php - 如何修复错误 "PHP Warning: oci_execute(): ORA-00932: inconsistent datatypes: expected DATE got NUMBER"?

php - 收到新询问时运行音频文件 PHP MySQL

php - 将大型对象索引到ElasticSearch中