Now that I'm starting to get back into PHP, I'm starting to remember why I gave it up in the first place. The most annoying thing on my plate at the moment is what I've come to term "PHP's white screen of death". When PHP gets a fatal error due to syntax or whatever, it seems like it will always die without actually sending anything to the browser. I've added the following to my .htaccess
, and it seems to work most of the time, but it doesn't work in these cases.
php_value display_errors 1
php_value display_startup_errors 1
php_value error_reporting 2147483647 # E_ALL
Am I missing something? At the moment I feel like I need to hit refresh every few lines of code I write, lest I make a mistake and have to search through many pages trying to track down that one little mistake I made...
EDIT: For example, given the two lines of code below:
$foo = array(':language' => $languageId;
$foo = array(':language' => $languageId);
The first will exhibit the white screen of death (ie, nothing at all printed to the browser), while the second will execute happily.
using
@inexistent_function_call();
in your code will cause the intepreter to quietly die and abort the script parsing. You should check for invalid functions and try not to use the error-supressing operator(the @ char )Try setting your error reporting level in your actual php files. Or, as others have suggested, check your server settings--it could be something in php.ini, or some restriction as regards your host. Don't just rely on .htaccess. Also, when troubleshooting, print_r any variables you might think fishy.
I have also seen such errors when the
fastcgi_params
orfastcgi.conf
config file is not properly included in the server configuration. So the fix for me was a silly:include /etc/nginx/fastcgi_params;
Took me an hour to find that out...
For those who use nginx and have a white screen even for file with
<?php echo 123;
. In my case I didn't have this required option for PHP in nginx config file:This option wasn't in fastcgi_params file, so PHP didn't work and there wasn't any errors in logs.
The following code should display all errors:
The only way to generate a blank page with this code is when you have a error in the shutdown handler. I copied and pasted this from my own cms without testing it, but I am sure it works.
Errors and warnings usually appear in
....\logs\php_error.log
or....\logs\apache_error.log
depending on your php.ini settings.Also useful errors are often directed to the browser, but as they are not valid html they are not displayed.
So
"tail -f
" your log files and when you get a blank screen use IEs "view" -> "source" menu options to view the raw output.