≡ Menu

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

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

Tweet itFacebook itGoogle+ itPDF itFound an error/typo on this page?

{ 8 comments… add one }

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

  • nixCraft October 6, 2008, 9:35 pm

    B!n@ry,

    Apache22 is for Apache version 2.2 under FreeBSD.

    HTH

  • peko October 7, 2008, 11:41 am

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

  • nixCraft October 7, 2008, 4:41 pm

    Peko,

    The post has been updated.

    I appreciate your post.

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

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

  • Gourine Khattib December 2, 2012, 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').')' ; }?>
    
  • Alastair January 17, 2013, 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…

  • Paulo July 17, 2015, 1:14 pm

    Other possible file location /etc/php5/apache2/php.ini

Leave a Comment