One of many things that can happen in programming is the dreaded – Screen of Nothing…
In the case of developing a PHP website script, the “Nothing” results in a Picture of a Polar Bear Eating a Vanilla Ice Cream in a Snowstorm, or “A White Screen of Nothing”.
That’s when it the fingers go straight to the head and the scratching begins… Hmmm what have I flummoxed this time?
So the answer is, as in all cases, Yelling at the screen and shouting “Show Me whats wrong!”
Well in the case of PHP, by default, it likes to keep this to itself to some degree and the reason is, if it happens on a live website, we don’t want the world to know. But as we are “Developing” I want it to scream back at me… “This is what’s wrong….” and show me.
So in the case of PHP ( and all languages in all environments have ways and means of screaming at you… ) we need to enable it.
And it all it takes is a little bit of code.
Enabling Error Reporting
A Google Search on the term “php enable error reporting” results in the following…
ini_set ('display_errors', >'1';
ini_set ('display_startup_errors','1');
error_reporting (E_ALL);
Now this needs to be placed in your code as early in the execution of your script as possible. In fact it should be the very first thing.
Usually you’ll either have a config that is always run either by way of an include statement on your pages.
Either way, it does help. Of course in a Development system you can change these default values so they are active for all of your development sites. Which is a bit safer as you might accidentally upload the above code in your files onto your live site(s) and that’s not good. But at the same time, you might want to have these uploaded in the case something weird is going on when your script is installed on the live server. But make sure to remove them once you have fixed it.
You should go and look up how to change these for your server depending upon it being Apache2 or NGINX etc.
Check your Error Logs.
In the case, somethings not “Leaping out at you” always check your Error Logs.