Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm setting up an Apache2, PHP 5.3.3 server running on CentOS 6. My web application uses the short tags <? and <?=. I can't seem to get the short tags enabled. When I run phpinfo() I see short_open_tag = off, however in /etc/php.ini I have this: short_open_tag = on (and yes I've restarted the server).

I've also tried using <?php ini_set('short_open_tag','1'); ?> at the start of a page and it still doesn't parse code in short tags.

The only thing I can think of is there's another php.ini file somewhere that is being used instead of, or overriding the one at /etc/php.ini.

Any advice?

share|improve this question
For completeness would you mind letting us know what the problem was ? – Iain Sep 3 '12 at 20:31
You can't fix the web application? – Michael Hampton Sep 3 '12 at 20:54
up vote 2 down vote accepted

I have a fairly default CentOS 6.3 system with PHP 5.3.3 to hand and it works as expected. Changing the value of short_open_tags in /etc/php.ini and restarting the httpd service just works.

PHP also reads the files in /etc/php.d so check that it's not being overridden in one of them.

If you want to check for other php.ini files then

find / -name php.ini 

A bit more information, the value of short_open_tag can be set in a .htaccess file too

php_value short_open_tag On
share|improve this answer

Most likely, you have eAccelerator or something similar enabled. Pre-compiled pages are not processed, so just clear eAccelerator cache, or (ugly) uninstall eAccelerator, restart Apache, re-install eAccelerator, restart Apache..

share|improve this answer

Make sure also that

  • no .htaccess file on the way to your script contains short_open_tag directive which might be conflicting (in my case this file in upper level directory was the source of problem)
share|improve this answer

I can see all answers above are partially correct only. In reality all 21st Century PHP apps will have FastCGI Process Manager(php-fpm) so once you have added php-info() into your test.php script and checked the correct path for php.ini

Go to php.ini and set short_open_tag = On

IMPORTANT: then you must restart your php-fpm process so this can work!

sudo service php-fpm restart

and then finally restart your nginx/http server

sudo service nginx restart
share|improve this answer

on centos6 /etc/php.ini should be the place, make sure it is not defined multiple times in the file.

By default, there is the description of tag in a "Quick Reference" section:

; short_open_tag
;   Default Value: On
;   Development Value: Off
;   Production Value: Off

don't add the tag there as it is set later on in a "Language Options" section (which would overwrite your setting):

; This directive determines whether or not PHP will recognize code between
; <? and ?> tags as PHP source which should be processed as such. It's been
; recommended for several years that you not use the short tag "short cut" and
; instead to use the full <?php and ?> tag combination. With the wide spread use
; of XML and use of these tags by other languages, the server can become easily
; confused and end up parsing the wrong code in the wrong context. But because
; this short cut has been a feature for such a long time, it's currently still
; supported for backwards compatibility, but we recommend you don't use them.
; Default Value: On
; Development Value: Off
; Production Value: Off
short_open_tag = Off
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.