Forum Moderators: phranque

Message Too Old, No Replies

HTACCESS code to turn short tags off?

         

naitsirhc26

6:18 pm on Jul 26, 2006 (gmt 0)

10+ Year Member



I was wondering if anybody could tell me the HTACCESS code to turn short tags off. With my host, they don't support <? anymore. They only support <?php Is there a code to change that? I can't go through the system and change the entire thing.

Little_G

6:35 pm on Jul 26, 2006 (gmt 0)

10+ Year Member



Hi,

php_flag short_open_tag on

should do it.

Andrew

naitsirhc26

6:45 pm on Jul 26, 2006 (gmt 0)

10+ Year Member



That doesn't do it

physics

8:41 pm on Jul 26, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I don't think that's something that can be set in .htaccess

You might be able to do a global search and replace though, something like


find ./ -name "*.php" -exec perl -i~ -wpe 's/\<\? /\<\?php /g' {} \;

"Find all .php files in this directory and below and switch all <? to <?php"
This is not tested and you should test it on a copy of the directory.

coopster

10:27 pm on Jul 26, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Using short open tags is not a great idea, as you are now experiencing.


Note: Using short tags should be avoided when developing applications or libraries that are meant for redistribution, or deployment on PHP servers which are not under your control, because short tags may not be supported on the target server. For portable, redistributable code, be sure not to use short tags.

Resource:
Basic syntax [php.net]

The PHP configuration directive short_open_tag [php.net] is of type PHP_INI_PERDIR [php.net] which means the entry can be set in

php.ini
,
.htaccess
or
httpd.conf
.

Do you want the tags on or off? Seems the title states you want them off, your first message suggests otherwise.

// On: 
php_flag short_open_tag on
// Off:
php_flag short_open_tag off

Another helpful resource:
How to change configuration settings [php.net]