Disable PHP Short tags
I’ve been bitten by this more than once in the past. Some servers allow PHP short tags (<?) and others don’t (<?php) and so when distributing your code it will look broken to some people – and work fine for others.
For me PHP Short Tags have been an issue when creating WordPress themes for Pro Theme Design. As such I learnt my lesson a long time ago – but as this recent post from Konstantin (a developer at Automattic) shows – even the best get caught out sometimes.
You could argue that if you’re only making ‘things’ for yourself that it doesn’t matter – but even then it’s not guaranteed. If you ever have to move server/ web host, or if your PHP settings get changed by your host, you could end up in the situation that stuff breaks and you’re not sure why.
I think the best way to solve this is to simply disable short tags in php.ini.
Doing this is really, and can be done in a couple of ways.
Disable PHP short tags with php.ini
All you have to do is load up php.ini and add/ change the following line, and then restart apache (I normally do this through my web host control panel):
Disable short tags with .htaccess
This is actually my preferred method because it’s so much simpler – and since I work with WordPress so much I always have a .htaccess file to hand. Just open up your .htaccess file and add the following line:
php_value short_open_tag 0
Tags photo from Shutterstock