SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Member
    Join Date
    Apr 2006
    Posts
    16
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    <?php ... ?> vs. <? ... ?> error

    I have just upgraded my LAMP server to PHP 5.1.1. Now my all my pages on all my sites are messed up. I have figured out that it is because I donot use <?php ... ?> to write php in. i just use <? ... ?>. Seems without the "php" in the tag it will not display properly.

    Is there a switch in the php.ini file or in apache that needs to be tripped so that it accepts all my thousands of legacy php tags?

    Thank you, Cesar

  2. #2
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,255
    Mentioned
    196 Post(s)
    Tagged
    2 Thread(s)

    short tags

    Short tags are not "legacy", they were/are an allowed short-cut. You may be able to compile your PHP server with "short_open_tag ON", but be aware that this can cause problems with <? XML files. IMHO much better to use <?php tags.

  3. #3
    SitePoint Member
    Join Date
    Apr 2006
    Posts
    16
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ok got it, update php.ini as follows.

    *php.ini becomes php.ini.rpmsave in PHP 5*

    ; Allow the <? tag. Otherwise, only <?php and <script> tags are recognized.
    ; 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.
    short_open_tag = On

    Now it works!! Woohoo.

  4. #4
    SitePoint Member
    Join Date
    Apr 2006
    Posts
    16
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Can you please explain how it may effect XML files?

    Also i understand its not a legacy tag, i was refernceing all my old scripts.

  5. #5
    Follow Me On Twitter: @djg gold trophysilver trophybronze trophy Dan Grossman's Avatar
    Join Date
    Aug 2000
    Location
    Philadephia, PA
    Posts
    20,578
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    XML documents start with the text <?xml

    PHP thinks that's the start of PHP code, and stops your program with a parse error.

    You'd need to do something like <? echo '<?xml'; ?>

  6. #6
    SitePoint Member
    Join Date
    Apr 2006
    Posts
    16
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ok got it. i have been doing this for a while. thanks for all the suggestions.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •