PHP 5.4 isn't exactly new; in fact the opposite is true! PHP 5.4 is end of life, but as our adoption rates show, as a community, PHP people aren't especially good at upgrading! I'm getting lots of questions now because some of the hosting providers, notably including Acquia's hosting, are finally upgrading away from those 5.2 and 5.3 offerings.
One thing in particular is tripping people up: the short open tag. I've had a few questions on this so here's the advice I am giving to clients and friends.
What Actually Changed
short_open_tag configuration directive was removed, but the short echo syntax
<?= is always available.
How To Upgrade Your Codebase
- If you have
<?= in your templates, leave it alone, those will still work
- If you have short tags
<? in your code, including in any of your libraries, then you need to do a global find-and-replace and turn them all into
If you have short tags somewhere in your codebase, you probably won't get errors, you'll just suddenly start seeing PHP code in your output as PHP doesn't recognise the tag and therefore doesn't evaluate the code! To find them, try searching for
<? followed by a whitespace character.
Hopefully that helps; there are a few gotchas to getting upgraded from older versions (especially from PHP 5.2) but this particular gotcha really isn't a problem and the instructions here should see you through.