PHP won’t show any errors, or just a blank page

Getting a white page (the infamous the white page of death) when you instruct your browser to open your website? Want to debug an error, but you don’t see error messages on the screen but you do in your logfiles?

Then you should enable the displaying of errors in PHP.

There are few ways you can do this. But the best (fool proof) way is to have this in your php.ini file:

; file /etc/php5/apache2/php.ini

; here goes other settings

display_errors = On

NB: Don’t forget to restart your webserver after changing PHP’s configuration for it to have effect: sudo service apache2 restart

More comprehensive options

If you want, you can enhance or broaden the displaying of error messages with the following.

There are a few options you can tweak:

The dangers of using ini_set in your PHP page for error displaying

Watch it! If you use ini_set(‘display_errors’, ‘on’); on your PHP page, then you might miss out.

What happens if a parsing-error occurs on the page that you put this ini-setting on? It would not get parsed so the ini-setting would not be set. So your errors still won’t be displayed.

Oops! So make sure you enable errors in your php.ini or .htaccess file instead of your PHP files.