error_get_last() returns NULL in PHP 7 when a custom exception handler is set

前端 未结 1 1570
暖寄归人
暖寄归人 2021-01-22 19:29

Ok, this took some time to break it down. Here it is:

There is an included faulty script which is the following for the remainder of this post:

faulty.php

相关标签:
1条回答
  • 2021-01-22 19:50

    PHP 7 throws a ParseError exception instead of triggering an error of type E_PARSE. The default exception handler seems to trigger an error if an uncaught exception is encountered. However if you replace it with set_exception_handler() it no longer happens unless you do it yourself.

    See PHP docs:

    PHP 7 changes how most errors are reported by PHP. Instead of reporting errors through the traditional error reporting mechanism used by PHP 5, most errors are now reported by throwing Error exceptions.

    0 讨论(0)
提交回复
热议问题