Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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
add comment

5 Answers

up vote 1 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
add comment

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
add comment

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
add comment

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
add comment

In Your .htaccess, add following

php_value short_open_tag 1

Reference:short tags in php

share|improve this answer
add comment

Your Answer

 
discard

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.