Skip to content

Fixing PHP short open tags

Find and replace in Eclipse PDTA PHP block is started with the tag <?php. However, there is also an alternative known as a "short open tag" which is to only use <?

The problem with using short open tags is that they conflict with xml parsers and for that reason, support for short open tags has to be enabled. By default, it's disabled and enabling deprecated features may be impossible if hosts don't allow it.

Every so often you may come upon a code base that was written using short open tags.

Often people are first confronted with this problem when they have a legacy code base, and either move it to a new server or upgrade php only to find that the site is spewing errors and no longer functional. In a worse case scenario portions of your php code will be plainly visible to end users due to the fact that the php parser is no longer parsing those blocks and simply returning them as html text.

There are a number of different approaches you can take to solve this problem. First you can turn on the support for short open tags, but as I mentioned previously, this is not recommended.

Continue reading "Fixing PHP short open tags"