如何调试 PHP WSOD?
我偶尔会遇到神秘的白屏死机 PHP 错误 - 即使使用以下设置,也不会显示或记录任何内容:
ini_set("error_reporting",E_ALL); ini_set("display_errors",true); ini_set("log_errors",true); ini_set("display_startup_errors",true); ini_set("html_errors",false); ini_set("error_log","/var/log/php_error_log");
我在某处读到输出缓冲或内存限制错误可能导致没有错误输出,但以前(例如)我发现 WSOD 只是由 __autoload() 寻找丢失的类文件引起的。
有没有人找到一种方法让这些错误可见?我讨厌注释掉代码块。
谢谢
Very occasionally I get a mystifying white-screen-of-death PHP error - nothing is displayed or logged, even with the following settings:
ini_set("error_reporting",E_ALL); ini_set("display_errors",true); ini_set("log_errors",true); ini_set("display_startup_errors",true); ini_set("html_errors",false); ini_set("error_log","/var/log/php_error_log");
I read somewhere that output buffering or memory limit errors can result in no error output, but previously (for example) I have found a WSOD simply caused by __autoload() looking for a missing class file.
Has anyone found a way to get these errors visible? I hate commenting out blocks of code.
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我最近遇到了类似的问题,结果发现我使用的软件包覆盖了日志记录设置,因此在某些情况下我永远看不到日志。因为您将设置放在 ini 文件中,所以我猜您使用 php.ini,所以有很多机会接近代码运行位置的内容正在更改设置。
我的建议是将
error_reporting(E_ALL | E_STRICT);
放入导致问题的文件中,看看是否可以改善情况。I had a similar problem recently and it turned out that the software package I was using was overriding the logging settings so that I was never seeing the logs in certain situations. Because your putting the settings in the ini file, i'm guessing your using php.ini, there is a lot of opportunity that something closer to where the code is run is changing the settings.
My advice would be to put
error_reporting(E_ALL | E_STRICT);
in the file that is causing the problem and see if that improves things.