Writing code without the words 'php' at start

Hi,

I work from two separate servers/pcs. On one, I have to start my code with ‘<?php’, while on the other I can start with just ‘<?’. Why is that and how can I adjust the other server so that I don’t have to write ‘php’ after the question mark? Thanks.

Chris

Prior to version 5.4 it’s the short_open_tag setting in php.ini

The full tag always works so always use it.

You should always use full (<?php) tags for a variety of reasons:

  • Compatibility. You will never be able to guarantee that short_open_tag will be set to true, and in some cases, may not have control over it
  • Collisions. IIS+ASP is notoriously famous for trying to parse <? as ASP if poorly configured. You want to avoid this.
  • Documentation. It only costs you three bytes and lifts all the ambiguity immediately, without the need for inspection.
Sponsor our Newsletter | Privacy Policy | Terms of Service