且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何跟踪“在第0行的Unknown中没有堆栈帧而引发的异常"?在PHP中?

更新时间:2023-02-24 07:46:34

这可能在没有堆栈框架的析构函数和异常处理程序中发生.但是,由于该消息非常有帮助,因此您唯一的选择是尝试使用echo查找错误(甚至可能是ob_end_flush()).可能是析构函数正在引发异常,或者正在调用引发异常的函数.找到越野车功能后,请在异常抛出部分周围添加try ... catch.

This can happen in destructors and exception handlers which don't have a stack frame. But since the message is so very helpful, your only option is to try to use echo to find the bug (and maybe ob_end_flush()). It may be that a destructor is throwing an exception, or is calling a function that throws an exception. Once you've located the buggy function, add a try...catch around the exception throwing part.

请注意,如果您的框架使用自己的错误处理,则必须关闭PHP配置中的警告和注意事项.特别是如果您有类似 ErrorException 之类的东西,因为它将警告变成异常

Note that if your framework uses its own error handling, you have to turn off warnings and notices in the PHP configuration. Especially if you have something like ErrorException, since it turns warnings into exceptions.