PHP Not Accepting <? Tag; Only Accepting <?php and <script> Tag

by Vivek Gite [Last updated: October 7, 2008]

Q. I'm using PHP along with latest version of Apache. Only <?php and <script> tags are recognized. Many of my scripts are broken. How do I allow the <? tag also?

A. You need to allow the <? tag by editing php.ini file. 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.

Open php.ini ( /etc/php.ini or /usr/local/etc/php.ini), enter:
# vi php.ini
Set short_open_tag to On:
short_open_tag = On
Save and close the file. Restart webserver:
# service httpd restart
OR
# /usr/local/etc/rc.d/apache22 restart

Want to read Linux tips and tricks, but don't have time to check our blog everyday? Subscribe to our daily email newsletter to make sure you don't miss a single tip/tricks. Subscribe to our weekly newsletter here!

{ 5 comments… read them below or add one }

1 B!n@ry 10.06.08 at 4:20 pm

Hi Vivek,

You have a typo mistake at the following line:
# /usr/local/etc/rc.d/apache22 restart

I think it should be:
# /usr/local/etc/rc.d/apache2 restart

regards,

2 vivek 10.06.08 at 9:35 pm

B!n@ry,

Apache22 is for Apache version 2.2 under FreeBSD.

HTH

3 peko 10.07.08 at 11:41 am

Don’t you have a typo here :
“You need to all the “You need to allow” ?

4 vivek 10.07.08 at 4:41 pm

Peko,

The post has been updated.

I appreciate your post.

5 B!n@ry 10.09.08 at 12:06 am

Aha, didn’t know that Vivek, thanks for the info :)

Leave a Comment

You can use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Tagged as: , , , , , , , , , , , ,

Previous post: FreeBSD: Install PHP xcache Opcode Cacher

Next post: FreeBSD Configure Apache PHP with mod_fastcgi Module