How to Enable Short Open Tags in PHP

Tyler Tyler (258)
Total time: 1 minute 

Enabling short open tags gives you access to opening your PHP script with <? rather than the full <?php and also includes <?= '...' ?> as a replacement for <?php echo '...'; ?>. These are very handy if you are used mixed HTML and PHP.

Here's everything you'll need to complete this guide:

PHP 4+×1

If you are not already logged into your machine, log in (ssh if necessary) and open /etc/php.ini. If you're familiar with vi:

vi /etc/php.ini

otherwise you can use

nano /etc/php.ini

You should find a line that says short_open_tag = Off change this to:

short_open_tag = On

If the line doesn't exist just add it.

Depending on your machine restart apache. On Centos you can run:

/etc/init.d/httpd restart

On Ubuntu,

/etc/init.d/apache2 restart

After restarting apache you should be able to use short tags.