set_error_handler()不适用于FATAL错误 [英] set_error_handler() doens't work for FATAL error
问题描述
我有一个简单的自定义错误处理程序,在错误日志文件中写入一些有用的调试信息。
I have a simple custom error handler that writes in a error log file some useful debug infos.
它适用于所有内容,但不会触发FATAL错误。
it's work for everything but it's not get triggered for FATAL error.
任何方法来解决这个问题?
Any way to solve this?
目前为了绕过这种情况,我已经注册了一个关机功能, error_get_last()
Currently to bypass this circumstance I have registered a shutdown function too that checks error_get_last()
推荐答案
不,这只是一个限制href =http://php.net/manual/en/function.set-error-handler.php =noreferrer> set_error_handler()
;它不处理所有错误。
Nope, that's just a limitation of set_error_handler()
; it doesn't handle all errors.
以下错误类型无法使用用户定义的函数进行处理:
E_ERROR
,E_PARSE
,E_CORE_ERROR
,E_CORE_WARNING
,E_COMPILE_ERROR
,E_COMPILE_WARNING
,大部分E_STRICT
在$ code> set_error_handler()被调用的文件中引发。
The following error types cannot be handled with a user defined function:
E_ERROR
,E_PARSE
,E_CORE_ERROR
,E_CORE_WARNING
,E_COMPILE_ERROR
,E_COMPILE_WARNING
, and most ofE_STRICT
raised in the file whereset_error_handler()
is called.
register_shutdown_function()
和 error_get_last()
是一个体面的解决方法。
The register_shutdown_function()
and error_get_last()
is a decent workaround.
这篇关于set_error_handler()不适用于FATAL错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!