简体   繁体   中英

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

The Logger class is defined in this way:

class Logger {
    public static function log() {
        echo "test";
}

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.

You also have to enable display_startup_errors to show Fatal errors:

Even when display_errors is on, errors that occur during PHP's startup sequence are not displayed. It's strongly recommended to keep display_startup_errors off, except for debugging.

Also see the Note for display_errors :

Although display_errors may be set at runtime (with ini_set() ), it won't have any affect if the script has fatal errors. This is because the desired runtime action does not get executed.

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.

I have exactly the same problem - I didn't manage to completely solve it, but I found out that all errors are correctly logged to a file, even though they are not displayed.

Just put this lines in your .htaccess/server config:

php_value       log_errors                      On
php_value       error_log                       "/path_to_logs/errors.log"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM