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"

RegEx and the Mod_rewrite reference sheet


Dave Child, a Brighton UK based Web developer offers a series of free Reference/Cheat sheets that I think most web developers will find of value. He obviously invested a lot of time and effort into them and it shows. He's created free cheat sheets for MySQL, Javascript, PHP, RGB colors and the subject of today's Gizmola.com entry, Apache mod_rewrite. If you've used Apache there's a good chance you've heard of mod_rewrite, although you might not understand what it can do for you. Lately, a lot of PHP scripts are including functionality that will create mod_rewrite rules and add them to a .htaccess file to support "SEO friendly" url's. Serendipity, which runs my blog, and the popular PHP Content Management System Mambo/Joomla are just two examples of packages that can do this for you.

For example, if your script uses a parameter like this: http://www.yoursite.com/home.php?id=5

A mod rewrite rule can allow users to use: http://www.yoursite.com/home/5/

Many search engines seem to penalize sites that use URL parameters, and are more likely to index and value the non-parameter version. Of course, that's not all that mod_rewrite can do. Many people use it for its ability to offer at least a layer of Hotlink protection, or to handle things like forwarding visitors from obsolete pages that might exist in a search engine to the new ones.

Using and understanding the black magic of mod_rewrite requires a basic understanding of Regular Expressions or as they are typically known: RegEx. If you're new to RegEx, think of them as wildcards on steroids. The October Lampsig meeting will present RegEx basics, and if you're in Los Angeles, definately try and attend the presentation, which will be given by Peter Benjamin. Check out Dave Child's succint reference for this powerful module whether or not you plan to attend Pete's presentation.

Continue reading "RegEx and the Mod_rewrite reference sheet"