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.
If the error is in PHP code, you can use error_reporting() function within your code to set to the report all.
However, this does not handle the situation when PHP crashes. Information about that is only available in server logs. Maybe you don't have access to those, but many hosting providers I've worked with have some way to let you access it. For example, the approach I like best is that it creates the error_log file in the current directory where .php resides. Try searching there or contact your hosting provider about this.
It is possible to register an hook to make the last error or warning visible.
adding this code to the beginning of you index.php will help you debug the problems.
open your php.ini, make sure it's set to:
restart your server.
Some applications do handle these instructions themselves, by calling something like this:
And thus overriding your .htaccess settings.
Dunno if it will help, but here is a piece of my standard config file for php projects. I tend not to depend too much on the apache configs even on my own server.
I never have the disappearing error problem, so perhaps something here will give you an idea.
Edited to show APPLICATON_LIVE
I'm always using this syntax at the very top of the php script.