23

I have recently installed Win8 on my computer. Then I instaled wamp 2.2 with php 5.4 and I am unable to make short tag work.

I have already put:

"short_open_tag = On"

into the php.ini file and I am sure that apache is loading the right file because the path to "Loaded Configuration File" in phpinfo() is good.

I would be glad for any piece of advice. Thanks.

6
  • 5
    Did you restart WAMP after making the change to your php.ini file? Sep 25, 2012 at 8:57
  • 4
    WARNING! did you read the comment above the short_open_tag? -> "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."
    – Jelmer
    Sep 25, 2012 at 9:00
  • <?=$someVar; ?> (as replace for <?php echo) should work regardless of the setting short_open_tag in PHP 5.4. Anything other you want to do with short tags isn't recommended, strongly!
    – dan-lee
    Sep 25, 2012 at 9:04
  • 1
    @DainisAbols I am referring to his question: Then I instaled wamp 2.2 with php 5.4
    – dan-lee
    Sep 25, 2012 at 9:08
  • 1
    Same issue with xampp. It's the php.ini file. short_open_tag = Off below the short_open_tag = On.
    – StackSlave
    Jan 27, 2015 at 23:01

6 Answers 6

54

I had the same problem recently after upgrading from PHP 5.3.18 to PHP 5.5.9..

I realized that for some reason, short_open_tag was appearing in my php.ini file twice.

If you did a find to get to that part of your php.ini file, try continuing the find to see if there is another instance.

4
  • 2
    And thanks from me. I spent quite a lot of time on this pesky thing. Oct 13, 2014 at 0:39
  • 1
    4 hours wasted. And some hair. Thank you!
    – jim smith
    Jun 14, 2016 at 13:15
  • 1
    who wrote the default php.ini should die horribly right now.
    – elbuild
    Aug 23, 2016 at 7:31
  • 1
    You save my life bro
    – odiszapc
    Mar 6, 2018 at 4:04
8

Set the :

asp_tags = On and short_open_tag = On 

in both the files \apache\Apache2.2.22\bin\php.ini and \bin\php\php5.4\php.ini and then restart the apache server.

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

Remember to restart your service (apache2, etc) for the edits to php.ini to take effect.

2
  • I restarted apache, that wasn't a problem I also added aspt_tags but still not working.. So i replaced all the shorten tags and I will not use I guess
    – marek_lani
    Sep 25, 2012 at 12:18
  • This solution only worked for me if I did the php_value short_open_tag 1 inside .htaccess. Not sure why it wouldn't work in php.ini, it is showing on in phpinfo() and I have restarted apache. using PHP 5.4- maybe that's it?
    – Eric Leroy
    Jun 5, 2013 at 20:50
7

Change the value of short_open_tag to On.

And if your php.ini file is located in /etc/php/5.6/fpm you need to restart the php5.6-fpm service with

sudo service php5.6-fpm restart
3
  • In my case: service php5-fpm restart
    – PYK
    Jan 16, 2022 at 15:55
  • Same for 7.4: sudo service php7.4-fpm restart
    – Klaaz
    Jan 24, 2022 at 14:59
  • In my case I'm using Debian in GCP with php 8.1 and apache so sudo systemctl restart php8.1-fpm did work for me Aug 18, 2022 at 6:13
5

Make sure to replace all

short_open_tag

occurrences within the php.ini file. In my case there were multiple places where it was defined. For me, the wrong setting was located under

;;;;;;;;;;;;;;;;;;;;
; Language Options ;
;;;;;;;;;;;;;;;;;;;;
0

The two most common mistakes are changing the value inside the commented section (lines starting with ; are not executed) and changing the wrong configuration.

In /etc/php/VERSION/ you will find multiple folders, such as cli, mods-available, apache, etc. based on your server set up. For instance, if you want to change the config for the PHP module used by Apache, you should go to /etc/php/VERSION/apache/php.ini.

People often modify the config in the cli folder by mistake as multiple online tutorials suggest the command php -i | grep "Loaded Configuration File" to find your php.ini file, however, this command will often direct you to the cli config.

When using Apache, you will also have to run sudo systemctl reload apache2 (for Debian-based distributions) to enable the changes.

0

I had the same problem recently after upgrading from PHP 5.4 to PHP 8.0

I realized that for i have to enable

short_open_tag = On

from the laragon as i am using the laragon in other case you can check your apache php.ini file.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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