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

by on October 6, 2008 · 7 comments· LAST UPDATED October 7, 2008

in , ,

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

TwitterFacebookGoogle+PDF versionFound an error/typo on this page? Help us!

{ 7 comments… read them below or add one }

1 B!n@ry October 6, 2008 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,

Reply

2 nixCraft October 6, 2008 at 9:35 pm

B!n@ry,

Apache22 is for Apache version 2.2 under FreeBSD.

HTH

Reply

3 peko October 7, 2008 at 11:41 am

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

Reply

4 nixCraft October 7, 2008 at 4:41 pm

Peko,

The post has been updated.

I appreciate your post.

Reply

5 B!n@ry October 9, 2008 at 12:06 am

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

Reply

6 Gourine Khattib December 2, 2012 at 11:54 am

Hello,
Please help
This is what gives me your component on the screen when I apply it with joomla 1.5.23

pgtitle?>
nbr_selection_fields) {?>
nbr_selection_fields){ case 1: ?> title1 ?>
sf1 ); $i
vertical){// disposicao vertical ?>
title1 ?>
sf1 ); $i
title2 ?>
title1 ?>
	title2 ?>
sf1 ); $i
vertical){// disposicao vertical ?>
title1 ?>
sf1 ); $i
title2 ?>
title3 ?>
title1 ?>
	title2 ?>
	title3 ?>
sf1 ); $i
vertical){// disposicao vertical ?>
title1 ?>
sf1 ); $i
title2 ?>
title3 ?>
title4 ?>
title1 ?>
	title2 ?>
	title3 ?>
	title4 ?>
sf1 ); $i
Button "view document"
show_downloads) echo JText::_('Downloads: ').$this->download_count;?>
'.JText::_('This Document Type does not exist!').'
('.JText::_('Probably recently deleted').')' ; }?>

Reply

7 Alastair January 17, 2013 at 3:00 pm

Well how about that… I stopped using Apache2 predominantly a long time ago except maintenance for clients and had been using lighttpd since. Regardless, I never use PHP’s short opening tag but whether someone added it into what was mainly my code or I thought I’d be really tricky/lazy, one occurrence in one script was giving me 500′s claiming mis-matched loops-brackets.

I didn’t know something so simple could cause so much frustration…thanks for the post!!! Now I know, I’ll hit anyone that I see who thinks the three-letter acronym (of the language they use to make a living) is too much to type…

Reply

Leave a Comment

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

Previous Faq:

Next Faq: