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:
<?php // your code ?>
you use:
<? // your code ?>
To enable PHP short style tags, you will need to edit your php.ini
file.
- Open
- Search for
short_open_tag
- Set it to
= On
(it isOff
by default) - Save the file
- 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.:
<?=$your_variable?>
http://php.net/manual/en/language.basic-syntax.phptags.php