A 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"
Continue reading "RegEx and the Mod_rewrite reference sheet"
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.