Zend 框架 - 未显示所有错误 [英] Zend Framework - not all errors are shown
问题描述
在一个动作方法中,我有以下代码摘录:
In an action method, I have the following excerpt of code:
error_reporting(E_ALL);
ini_set('display_errors', '1');
Logger::log('test');
Logger 类是这样定义的:
The Logger class is defined in this way:
class Logger {
public static function log() {
echo "test";
}
我故意忘记了函数的右大括号来演示问题.调用该操作时,屏幕上绝对不会呈现任何内容.这是什么类型的错误,为什么不显示,即使我将 PHP 配置为显示所有错误,如上所示?
I deliberately forgot the closing brace of the function to demonstrate the problem. When the action is called, absolutely nothing is rendered on the screen. What type of error is this, and why is it not displayed, even though I configured PHP to show all errors, as shown above?
当然,如果我加上缺少的大括号,一切都会好的.
Of course, if I add the missing brace, everything is OK.
推荐答案
您还必须启用 display_startup_errors
显示致命错误:
You also have to enable display_startup_errors
to show Fatal errors:
即使打开display_errors
,在PHP 启动过程中发生的错误也不会显示.强烈建议关闭 display_startup_errors
,除了调试.
Even when
display_errors
is on, errors that occur during PHP's startup sequence are not displayed. It's strongly recommended to keepdisplay_startup_errors
off, except for debugging.
另请参阅 display_errors
的注释:
虽然 display_errors
可以在运行时设置(使用 ini_set()
),但如果脚本有致命错误,它不会有任何影响.这是因为未执行所需的运行时操作.
Although
display_errors
may be set at runtime (withini_set()
), it won't have any affect if the script has fatal errors. This is because the desired runtime action does not get executed.
您可以在 Zend Framework 的 application.ini 中设置这两个值.旁注:如果您设置 error_reporting(-1)
它将报告 (!display) 所有错误,包括 E_STRICT
和任何未来的添加.
You can set both values in Zend Framework's application.ini. On a sidenote: if you set error_reporting(-1)
it will report (!display) all errors, including E_STRICT
and any future additions.
这篇关于Zend 框架 - 未显示所有错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!