We’ve all been there. Happily writing our PHP for some template or another. But then you save your file and refresh the page and…the screen stays completely white.
So why does this happen? Most likely you’ve made a syntax error somewhere. Like, say, forgetting a semi-colon or curly bracket. Another reason is that you’ve reached the memory limit of your server. The latter will usually happen when you enable a particularly poor plugin or theme.
The reason this comes up as a white screen of DOOM is because your errors are being suppressed.
While this isn’t necessarily a bad thing on a production server (though, you do test your code before pushing it live, right? Right?), it can be very inconvenient while you’re developing a new template or WordPress plugin.
To get rid of this inconvenience on a development server is fairly simple. All you need to do is open up your
wp-config.php file and locate the line that says:
define('WP_DEBUG', false);. Change
true and you should be good to go. If it’s not there, you can add it anywhere above where it says
/* That's all, stop editing! Happy blogging. */.
Should this not work (it’s somewhat unlikely, but it’s possible), you can also set PHP’s error reporting on the fly.
And there’s that. My first quick tip. I’ll most likely post more of these in the future. If you’re still having issues with errors plaguing your WordPress website, drop me a line and we’ll figure it out together.