Recent Posts

Showing posts with label display_errors. Show all posts
Showing posts with label display_errors. Show all posts

How to solve: Nothing is seen. The page is empty and white in PHP

Also known as the White Page Of Death or White Screen Of Death. This happens when error reporting is turned off and a fatal error (often syntax error) occurred.

If you have error logging enabled, you will find the concrete error message in your error log.

Sometimes it might be more straightforward to temporarily enable the display of errors. The white page will then display the error message. Take care because these errors are visible to everybody visiting the website.

This can be easily done by adding at the top of the script the following PHP code:

ini_set('display_errors', 1); error_reporting(~0);
The code will turn on the display of errors and set reporting to the highest level.

Since the ini_set() is executed at runtime it has no effects on parsing/syntax errors. Those errors will appear in the log. If you want to display them in the output as well (e.g. in a browser) you have to set the display_startup_errors directive to true. Do this either in the php.ini or in a .htaccess or by any other method that affects the configuration before runtime.

Looking in the log or using the display, you will get a much better error message and the line of code where your script comes to halt.