problem with php tags <? or <?php

Discussion in 'PHP' started by fatabbot, Sep 9, 2006.

  1. #1
    Hi

    I'm installing php on a laptop and when i make a file phpinfo.php with content:
    <? echo phpinfo() ?> and open the page, the source shows "<? echo phpinfo() ?>" instead of the usual page with the php info.

    when i change the source to <?php echo phpinfo() ?>
    i get all the info...
    How can i make it so that apache/php recognizes my <? ?> tags ? Because on my other pc all my php code is made with these tags.
     
    fatabbot, Sep 9, 2006 IP
  2. Caydel

    Caydel Peon

    Messages:
    835
    Likes Received:
    47
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Simple solution, just find/replace <? with <?php

    I think <?php is the standard anyways.
     
    Caydel, Sep 9, 2006 IP
  3. fatabbot

    fatabbot Well-Known Member

    Messages:
    559
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    138
    #3
    I don't like that solution very much :p
    It should work on this pc the same way.
     
    fatabbot, Sep 9, 2006 IP
  4. Caydel

    Caydel Peon

    Messages:
    835
    Likes Received:
    47
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Well, FWIW, I don't think Apache will recognize the tags the way you have them.

    Your call!
     
    Caydel, Sep 9, 2006 IP
  5. fatabbot

    fatabbot Well-Known Member

    Messages:
    559
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    138
    #5
    Why does it recognize the tags on my other pc ? same apache and php version.
     
    fatabbot, Sep 9, 2006 IP
  6. Caydel

    Caydel Peon

    Messages:
    835
    Likes Received:
    47
    Best Answers:
    0
    Trophy Points:
    0
    #6
    
    <?php
    
                         /"\
                        |\./|
                        |   |
                        |   |
                        |>~<|
                        |   |
                     /'\|   |/'\..
                 /~\|   |   |   | \
                |   =[@]=   |   |  \
                |   |   |   |   |   \
                | ~   ~   ~   ~ |`   )
                |                   /
                 \                 /
                  \               /
                   \    _____    /
                    |--//''`\--|
                    | (( +==)) |
                    |--\_|_//--|
    
    ?>
    
    Code (markup):
    calm down - it's just a joke...;)

    Just saw you changed your post. Figured I would leave the finger anyways, took a lot of work.
     
    Caydel, Sep 9, 2006 IP
  7. fatabbot

    fatabbot Well-Known Member

    Messages:
    559
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    138
    #7
    Yeah mine too :p

    I'm just looking for a solution :(
     
    fatabbot, Sep 9, 2006 IP
  8. sachin410

    sachin410 Illustrious Member

    Messages:
    6,422
    Likes Received:
    573
    Best Answers:
    0
    Trophy Points:
    410
    #8
    Are your short tags enabled?

    Search for "short_open_tag " in your php.ini and see if it is on.
     
    sachin410, Sep 9, 2006 IP
  9. sea otter

    sea otter Peon

    Messages:
    250
    Likes Received:
    23
    Best Answers:
    0
    Trophy Points:
    0
    #9
    In php.ini, make sure you have the line

    
    short_open_tag = On
    
    Code (markup):
    Chances are it is currently set to "Off".

    Don't forget to restart Apache after making the change!
     
    sea otter, Sep 9, 2006 IP