Zero logo

PHP Short Open Tags


  • Do not use the short form (<?   ?>) of PHP open tag.
  • Use the long form of PHP open tag (<?php   ?>).
  • Always switch "short form open tags" to "off" in the PHP configuration file.


Using short tags is discouraged because they are in conflict with XML's open tag - '<?xml'. If the file is actually XML, the PHP interpreter will process everything after the '<?' as PHP code, resulting in a parsing error.

Another reason to always use full PHP opening tags is to avoid the unknown. For example, a hosting provider that doesn't allow short open tags (<?   ?>) on their servers.

Testing older scripts

For testing older scripts, you can switch short open tags "on" temporarily. After testing, be sure to switch short form open tags "off" and retest the scripts

Convert older scripts as follows:

Replace all occurrences of (<?   ?>) with (<?php   ?>)
Replace all occurrences of (<?=) with (<?php echo)
Replace all occurrences of (<%   %>) with (<?php   ?>)

There's a similar issue with ASP-like <% %> tags. The Uniform Server Zero default is asp_tags = Off
Replace all occurrences of (<%   %>) with (<?php   ?>)