問題描述
我有一個簡單的自定義錯誤處理程序,可以在錯誤日志文件中寫入一些有用的調試信息.
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()
推薦答案
不,那只是 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
在調用 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() 對致命錯誤不起作用的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!