如何调试 PHP WSOD?

发布于 2024-09-27 16:37:40 字数 406 浏览 0 评论 0原文

我偶尔会遇到神秘的白屏死机 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

哥,最终变帅啦 2024-10-04 16:37:41

我最近遇到了类似的问题,结果发现我使用的软件包覆盖了日志记录设置,因此在某些情况下我永远看不到日志。因为您将设置放在 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文