Impaled by a PHP Open Tag

I was recently moving a WordPress blog and ran into a problem where a series of errors were appearing on screen in the target location.

Back on the original site, all was fine, so what was different?

Naturally, I went through a whole host of checks, including:

  • PHP version
  • .htaccess file
  • Apache config files
  • The database
  • Copy of the theme
  • Duplicating ALL the site files
  • Version of WordPress used…etc.

You get the idea…but I kept drawing a blank.

Changing the debug level in the wp-config file was helpful:

Let’s take a look at the code there:

I could now see where it was “beginning” to go wrong, but setting that value only took away the PHP error – the bad text remained. Then I looked up the source file and saw this:

Look closely (and pretend you can’t remember the name of this post!). It’s the “<?” but what’s wrong with that? That’s a valid opening tag, isn’t it> Well, yes and no. It is valid, but only if you say it is in your php.ini file.

For me, on my system with Apache, I need to head here:

In your case, should you suffer this predicament, you need to alter the folder for the version of PHP you are using. OK, back to the file. Edit that and search for this: “short_open_tag” and set this to “On” like so:

Or should you!? Whilst that will fix your problem, that style is deprecated and can cause some problems with XML files.

Honestly, the best approach is to edit your file and make all opening tags begin with  <?php

So that’s what I did 🙂


Written by Stephen Moon
email: stephen at

Hey! Did you enjoy reading this? If you did and would like an email when I add new content, just subscribe to my list. You can unsubscribe at any time.

Leave a Reply

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