PHP not displaying errors even though display_errors = On

wowpatrick picture wowpatrick · Jun 25, 2011 · Viewed 128.4k times · Source

I have a Ubuntu server running Apache2 with PHP 5. In the php.ini I set display_errors = On and error_reporting = E_ALL | E_STRICT, but PHP is still not displaying error messages. I'm also using Apache virtual hosts.

Also, what is the most strict error reporting PHP5.3 has to offer? I want my code to as up-to-date and future-proof as possible.

Answer

Ray picture Ray · Jun 26, 2011

You also need to make sure you have your php.ini file include the following set or errors will go only to the log that is set by default or specified in the virtual host's configuration.

display_errors = On

The php.ini file is where base settings for all PHP on your server, however these can easily be overridden and altered any place in the PHP code and effect everything following that change. A good check is to add the display_errors directive to your php.ini file. If you don't see an error, but one is being logged, insert this at the top of the file causing the error:

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

If this works then something earlier in your code is disabling error display.