blog feature image
WordPress

When there is a space in your php file no one can hear you scream

Except for perhaps most people on my street, nobody could hear my cries of anguish when met with first of all the “white screen of death” in a WordPress site I was working on.

Couple this with also being unable to access the Dashboard area of WordPress, with an error such as:

Warning: Cannot modify header information – headers already sent by (output started at //home/htdocs/wordpress/wp-config.php:1) in /home/htdocs/wordpress/wp-login.php on line 12

Or something similar.

Both on a live site. Whoops.

Issues with functions.php

At least I knew what I had been editing (or had recently edited) at the time so my first instinct was to resolve the “white screen of death”. This meant re-visiting live theme’s functions.php. See, I had done a rookie error here, and edited the file within the WordPress Dashboard.

Somewhere along the lines of my edits I had inadvertently removed some lines relating to one of the php functions and, I don’t know, WordPress was grumpy with me for doing that. Go figure.

Somehow I managed to re-enter what was missing, but the biggest lesson to learn there is to always use a text editor (there is no Undo when editing via WordPress back-end) as it would have then been a whole lot easier to correct my mistake.

Although this meant the site was at least now accessible to the public, this wasn’t going to solve my “cannot modify header information” issue when trying to log in.

Issues with wp-config.php

Knowing that I had made some edits here also, I re-opened my wp-config.php file looking for some silly edits or deleted text or something, but no. Nothing looked out of place.

I had a second look. Still nothing looked out of place. I pondered having a third look.

And then I noticed the space. Yep, a space. An extra line break at the bottom of the file. Removing that line space solved the issue.

Why WordPress / PHP gets all huffy with such a thing was beyond my frustrated comprehension at the time, but you can be sure that never again has there been an extra line break appearing in my wp-config.php file.

Please share:

Leave a Reply

Your email address will not be published. Required fields are marked *

Notify via Email Only if someone replies to My Comment