The evil short open tag in php
Our client asked for a short portion of their php code to be modified. Since I'm a Java guy and so is my team lead, we asked our new developer (web developer) to do the dirty stuff for us. Good, he was able to finish quick. But then, when I tested the code he wrote, the php script would just show as plain text. It's been years since I programmed in PHP. But it's a good thing I still remember some stuff about it. From the php.ini file it said:
; Allow the <? tag. Otherwise, only <?php and <script> tags are recognized.
; NOTE: Using short tags should be avoided when developing applications or
; libraries that are meant for redistribution, or deployment on PHP
; servers which are not under your control, because short tags may not
; be supported on the target server. For portable, redistributable code,
; be sure not to use short tags.
short_open_tag = Off
I was used to doing <?php ?> instead of <? ?>. The short_open_tag or <? ?> makes your code less readable IMHO. It's also unsafe since short_open_tag is not enabled by default on other servers. Thanks to garri of devpinoy for pointing out that I can configure this on the server. Well, not actually the server but php.ini.