如何显示PHP错误? [英] How do I get PHP errors to display?
问题描述
我已经检查了我的PHP ini文件(php.ini
)并设置了display_errors
,错误报告也为E_ALL
.我已经重新启动了Apache Web服务器.
I have checked my PHP ini file (php.ini
) and display_errors
is set and also error reporting is E_ALL
. I have restarted my Apache webserver.
我什至把这些行放在脚本的顶部,它甚至没有捕获简单的解析错误.例如,我用"$"
声明变量,并且不关闭语句";"
.但是我所有的脚本都显示有关这些错误的空白页面,但是我想在浏览器输出中实际看到错误.
I have even put these lines at the top of my script, and it doesn't even catch simple parse errors. For example, I declare variables with a "$"
and I don't close statements";"
. But all my scripts show a blank page on these errors, but I want to actually see the errors in my browser output.
error_reporting(E_ALL);
ini_set('display_errors', 1);
还有什么要做?
推荐答案
这始终对我有用:
ini_set('display_errors', '1');
ini_set('display_startup_errors', '1');
error_reporting(E_ALL);
但是,这不会使PHP显示解析错误-显示这些错误的唯一方法是使用以下代码行修改php.ini:
However, this doesn't make PHP to show parse errors - the only way to show those errors is to modify your php.ini with this line:
display_errors = on
(如果您无权访问php.ini
,则将此行放在.htaccess
中也可能有效):
(if you don't have access to php.ini
, then putting this line in .htaccess
might work too):
php_flag display_errors 1
这篇关于如何显示PHP错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!