PHP logo

Another post from the archives: I am running a WAMP development environment at home and at work. I am always looking for new ways to fine-tune my set-up. Here is one…

The short open tags option allow you to leave off the “php” in the opening tag of your code block. So, instead of:

you use:

To enable PHP short style tags, you will need to edit your php.ini file.

  1. Open 
  2. Search for short_open_tag
  3. Set it to = On (it is Off by default)
  4. Save the file
  5. Restart your web server

The advantage: you get to save yourself typing 3 characters for every PHP code block you write.

The disadvantages: loss of portability: your code will not work on a server where short tags have not been enabled — and many ISP’s are not willing to edit the php.ini file on the server.

Also note that as of PHP 5.4.0 <?= will always work, regardless of your short_open_tag setting, e.g.

http://php.net/manual/en/language.basic-syntax.phptags.php

Leave a Reply