Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
168 views
in Technique[技术] by (71.8m points)

php - 如何显示PHP错误?(How do I get PHP errors to display?)

I have checked my PHP init file ( php.ini ) and display_errors is set and also error reporting is E_ALL .

(我检查了我的PHP初始化文件( php.ini ),并设置了display_errors ,并且错误报告为E_ALL 。)

I have restarted my Apache webserver.

(我已经重新启动了Apache Web服务器。)

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);

What is left to do?

(还剩下什么呢?)

  ask by Abs translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

This always works for me:

(这总是对我有用:)

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

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:

(但是,这不会使PHP显示解析错误-显示这些错误的唯一方法是使用以下代码行修改php.ini:)

display_errors = on

(if you don't have access to php.ini , then putting this line in .htaccess might work too):

((如果您无权访问php.ini ,那么将此行放在.htaccess也可能有效):)

php_flag display_errors 1

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...