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"

PHPeclipse Annoyances

I have become an Eclipse convert. Eclipse is an IDE which I use to develope my PHP projects. Eclipse is open source and free, and has too many features to even begin listing. It also has a myriad of modules supporting language specific extensions and support for programmer tools like CVS.

I've also been using the PHPeclipse extension, which adds a number of nice PHP specific features and in eclipse terminology, an eclipse perspective, which is especially useful if you develope in an all-in-one environment with a local apache and php instance on your workstation. This allows you to iterate rapidly, as your changes can be instantly examined in the docked browser window, and ostensibly give's one access to php's debugging hooks. I'll admit I've never tried this, although having a debugger available is always a nice feature for any platform.

The main things I want out of PHPeclipse are color syntax hilighting, a class and function browser window that makes it quick to jump around inside your code, and PHP functionn prototypes so I know what the argument list is for all those useful built-ins like substr and array_sort, all of which you get with PHPEclipse. The class browser works well, except that it's not smart enough to resolve includes, and for this reason, rarely has visibility into the classes you're using because they're in their own class file. You can always open these in a seperate source window of course, as your workspace you can have numerous files open, all easily accessible from tabs. Continue reading "PHPeclipse Annoyances"