本文介绍了即使 display_errors = On,PHP 也不显示错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一台运行 Apache2 和 PHP 5 的 Ubuntu 服务器.在 php.ini 中,我设置了 display_errors = Onerror_reporting = E_ALL |E_STRICT,但 PHP 仍未显示错误消息.我也在使用 Apache 虚拟主机.

I have a Ubuntu server running Apache2 with PHP 5. In the php.ini I set display_errors = On and error_reporting = E_ALL | E_STRICT, but PHP is still not displaying error messages. I'm also using Apache virtual hosts.

另外,PHP5.3 提供的最严格的错误报告是什么?我希望我的代码尽可能保持最新且面向未来.

Also, what is the most strict error reporting PHP5.3 has to offer? I want my code to as up-to-date and future-proof as possible.

推荐答案

您还需要确保您的 php.ini 文件包含以下设置,否则错误只会出现在日志中默认设置或在虚拟主机的配置中指定.

You also need to make sure you have your php.ini file include the following set or errors will go only to the log that is set by default or specified in the virtual host's configuration.

display_errors = On

php.ini 文件是服务器上所有 PHP 的基本设置,但是这些很容易被覆盖和更改 PHP 代码中的任何位置,并影响更改后的所有内容.一个好的检查方法是将 display_errors 指令添加到您的 php.ini 文件中.如果您没有看到错误,但正在记录一个错误,请将其插入导致错误的文件顶部:

The php.ini file is where base settings for all PHP on your server, however these can easily be overridden and altered any place in the PHP code and effect everything following that change. A good check is to add the display_errors directive to your php.ini file. If you don't see an error, but one is being logged, insert this at the top of the file causing the error:

ini_set('display_errors', 1);
error_reporting(E_ALL);

如果这有效,那么您代码中较早的部分正在禁用错误显示.

If this works then something earlier in your code is disabling error display.

这篇关于即使 display_errors = On,PHP 也不显示错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-26 08:28