How to enable short open tags in PHP

  • by Tyler (231)
  • Time to complete: 1 minute

Enabling short open tags gives you access to opening your PHP script with "" as a replacement for "". These are very handy if you are used mixed HTML and PHP.

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


2

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.

3

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.