I am Hack Sparrow
Captain of the Internets.

Why not to use PHP short opening tags

Should you use PHP short opening tags?

The short answer is "NO, you should not". The reason why you should not use PHP short tags is explained below.

Reasons why not to use PHP short opening tags

  1. Your hosting server may not support short opening tags (<?). After spending hours on development on your development server (localhost?), when you upload the code online, you will find everything is broken.
  2. If you are sharing your code (open source etc.), some users might use them on a host which does not support PHP short code. They are going to curse you for it.
  3. <?php= generates confusion with XML declarations. Your code will break, and you will have very very hard time figuring out why.
  4. <%, the ASP opening tag! Probably one of the most idiotic 'features' in PHP - the ability to write PHP code with ASP opening tags. Avoid anything idiotic.
  5. Even the creators of PHP are suggesting not using short tags. Infact, short tags will be gone in PHP 6. Make your code future-proof.
    It's been recommended for several years that you not use the short tag "short cut" and instead to use the full tag combination. With the wide spread use of XML and use of these tags by other languages, the server can become easily confused and end up parsing the wrong code in the wrong context. But because this short cut has been a feature for such a long time, it's currently still supported for backwards compatibility, but we recommend you don't use them.
    - php.ini file

How to enable/disable PHP short tags on your server
In case you need to disable or enable PHP short opening tags do the following. Open php.ini file and find these directives - short_open_tag and asp_tags - and set them to "On" or "Off" as per your requirement.


short_open_tag = Off
asp_tags = Off


  1. PHP Short Open Tag
  2. PHP ASP Tags

Make a Comment