How to enable PHP short tags?


I have a web application on a Linux server which starts with <?

I needed to copy this application to a windows environment and everything is working fine except that an SQL statement is being rendered differently. I don't know if this has to do with the script beginning with <?php instead of <? because I don't know from where to enable the <? from the PHP.ini so I changed it to <?php

I know that these 2 statements are supposed to mean the same but I need to test it with <? in order to ensure that the application is exactly the same. This way I can eliminate another possibility.


5/12/2013 3:41:45 PM

Accepted Answer



in php.ini

And restart your Apache server.

2/11/2012 5:07:45 AM

This can be done by enabling short_open_tag in php.ini:

short_open_tag = on

If you don't have access to the php.ini you can try to enable them trough the .htaccess file but it's possible the hosting company disabled this if you are on shared hosting:

php_value short_open_tag 1

For the people thinking that short_open_tags are bad practice as of php 5.4 the <?= ... ?> shorttag will supported everywhere, regardless of the settings so there is no reason not to use them if you can control the settings on the server. Also said in this link: short_open_tag

Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow