Ashvin
Ashvin

Reputation: 4020

How to set short tag(<?) in PHP?

I am using WAMPP for PHP server and in programming short tag use create a problem. I knew that it possible by change something in php.ini file but I don't know the setting for that please help me for that.

example:

<? echo "hi"; ?> //error....want to allow this also.
<?php echo "hi"; ?> //ok

I found this in PHP config setting file but what changes require I don't know...

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

Upvotes: 10

Views: 38502

Answers (6)

IqbalBary
IqbalBary

Reputation: 1126

Sometime setting short_open_tag = On on your php.ini will not work because in some cases, short_open_tag define more than one. So find all short_open_tag and set On or 1.

short_open_tag = On 

Upvotes: 1

Quirijn
Quirijn

Reputation: 3547

Wamp 2.5 contains two versions of php.ini. If you're running php inside Apache (as I guess you are) you need to change the one in \bin\apache\apache2.4.9\bin.

Upvotes: 0

Hafiz
Hafiz

Reputation: 4277

Click on your wamp icon then "PHP". Then click on "PHP Settings". There should be an option for "short open tag" which you should enable by clicking on it, it should show a check mark. Your wamp server will automatically restart in a few seconds and then short open tag will be enabled.

For non-wamp you need to go to your php.ini file and uncomment short_open_tag = On

Upvotes: 11

Diablo
Diablo

Reputation: 3418

In your php.ini change the short_open_tag = Off if it's there to this:

short_open_tag = On

Upvotes: 20

Carter Cole
Carter Cole

Reputation: 924

sed -i 's/short_open_tag = Off/short_open_tag = On/g' /etc/php.ini
grep -n short_open_tag php.ini 

first line does inlien replace of php.ini to turn on short tags second makes sure its there

Upvotes: 1

Nik
Nik

Reputation: 4075

set short_open_tag = 1 in your php.ini file.

Upvotes: 5

Related Questions