how i can use <? instead of <?php

Discussion in 'PHP' started by Kyriakos, Sep 16, 2008.

  1. #1
    hi everyone,

    i want to use <? instead of <?php. is this possible? i'm using WAMP Server 2.0.
     
    Kyriakos, Sep 16, 2008 IP
  2. serialCoder

    serialCoder Guest

    Best Answers:
    0
    #2
    yep, although it's not advisable

    edit your php.ini file, change short_open_tag = On, restart the apache server
     
    serialCoder, Sep 16, 2008 IP
  3. Kyriakos

    Kyriakos Active Member

    Messages:
    155
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    51
    #3
    thank you my friend
     
    Kyriakos, Sep 16, 2008 IP
  4. Limotek

    Limotek Peon

    Messages:
    165
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #4
    I read the same that it was better practice to use '<?php' instead of '<?' but I'm not sure why. It is because '<?' can be interpreted as something else on some servers?
     
    Limotek, Sep 17, 2008 IP
  5. chessh

    chessh Peon

    Messages:
    16
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    It isn't a good ideea to use <? instead of <?php because <? is used as starting tag in XML (eXtensible Markup Language), so when you use both languages it can create confusions. So I advice you strongly to use <?php and not the shorter tags :)
     
    chessh, Sep 17, 2008 IP
  6. cornetofreak

    cornetofreak Peon

    Messages:
    170
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    0
    #6
    yea use <?php ?> ... there are ASP type tags aswell that u can use <% %> :)
     
    cornetofreak, Sep 17, 2008 IP
  7. d.arbib

    d.arbib Guest

    Best Answers:
    0
    #7
    Using <?php ?> to reduce the dependence to php.ini setting.
     
    d.arbib, Sep 17, 2008 IP
  8. Panzer

    Panzer Active Member

    Messages:
    381
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    58
    #8
    <? Wont read as an XML tag, you shouldn't have PHP code in your XML feed... It also isn't a valid XML tag as all tags need to be closed. It would have to be <?> </?>.

    Its best practice to use <?php as some servers have short tags (<?) turned off.
     
    Panzer, Sep 17, 2008 IP
  9. Limotek

    Limotek Peon

    Messages:
    165
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #9
    Ah I see. Thanks for explaining. I've only ever used servers that must allow short tags as I haven't experienced any problems to date. Agree <?php is better practice.
     
    Limotek, Sep 18, 2008 IP