Login |  Register 
Your open source Rocks PHP Library has really made developing PHP easier!
Alan
 

White screen of death

If your PHP installation suppresses error messages and encounters a fatal error before your PHP script produces any output then PHP will exit and return an HTTP response without any content!

Another potential cause of this issue is to have white space after a closing ?> therefore try deleting all white space after the closing php tag.

This is obvioulsy quite difficult to debug therefore you should use turn on error reporting.

Another good way of debugging this issue is by using PHP's die function to stop execution after where you think the problem is.

if ($problem == 'me")
{
   echo "Problem is me";
}

die('reached here');

if ($problem == "you")
{
   echo "Problem is you";
}
If the die text doesn't show then you can be sure that the PHP has never executed that code. Therefore in the example above the text 'reached here' won't appear as the error is above the call to the die function. So you can move the die function call further forward in the code, until the die function is called. Once this happens you know you have found your problem. To be sure comment out the offending code and echo something after it.

If you now see something, you can be sure this is what is causing your issues. This is another reason why you should implement logging as this way you can see what is happening even when no output is being shown on the screen.


No comments have been provided.
security image
Written by Dominic Skinner
Last Updated: 2011-10-25 16:00:38