如何显示 PHP 错误? [英] How do I get PHP errors to display?
问题描述
我检查了我的 PHP ini 文件 (php.ini
) 并且设置了 display_errors
并且错误报告也是 E_ALL
.我已经重新启动了我的 Apache 网络服务器.
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屋!