PHP的解析错误将不会显示 [英] php parse errors won't show
问题描述
我正在运行ubuntu 10.04 + nginx + php-fpm 5.4
I'm running ubuntu 10.04 + nginx + php-fpm 5.4
如果我在php.ini中设置了display_errors = On
,则会显示所有错误.如果相反,我将其设置为关闭,然后使用ini_set('display_errors,'1');它们也会直接在脚本中显示,但不会显示解析错误,只是空白页.我也尝试过error_reporting和E_STRICT,但我找不到办法!
If I set display_errors = On
in php.ini all errors are printed. If Instead I set that to off and then use ini_set('display_errors, '1'); directly in the script they will show as well but not the parse errors, just a blank page. I tried to play with error_reporting too and E_STRICT but I couldn't find a way!
推荐答案
如果在php.ini
中禁用display_errors
,随后又使用ini_set()
在PHP脚本中启用它,则只有在包含该ini_set()
调用的行已执行.
If you disable display_errors
in php.ini
, and later enable it in your PHP script using ini_set()
, it will only be enabled after the line containing that ini_set()
call has been executed.
解析错误发生在 PHP脚本启动之前 –解析PHP文件时(因此称为解析错误"名称).
Parse errors occur before the PHP script even starts -- when the PHP file is parsed (hence the "parse error" name).
这意味着它们在您的ini_set()
甚至没有被执行的机会之前就发生了-这意味着,在您的情况下,当解析错误发生时,display_errors
没有启用;结果,您什么也不会显示.
Which means they occur before your ini_set()
has even a chance of being executed -- which means that, in your case, display_errors
is not enabled when the parse error occurs ; and, as a consequence, you don't get anything displayed.
这篇关于PHP的解析错误将不会显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!