<?php ?>

Discussion in 'PHP' started by cancer10, Jun 9, 2007.

  1. #1
    For some reasons my php code does not work unless i put the php keyword after the ? in my code as shows in the following example.

    <?php
    echo "Hello";
    ?>
    Code (markup):
    The above code works



    <?
    echo "Hello";
    ?>
    Code (markup):
    The above code does not work


    What settings do i need to do to make the second code work?

    Thanx
     
    cancer10, Jun 9, 2007 IP
  2. krakjoe

    krakjoe Well-Known Member

    Messages:
    1,795
    Likes Received:
    141
    Best Answers:
    0
    Trophy Points:
    135
    #2
    allow_short_tags needs to be enabled in your php.ini

    PHP's official opening tag is infact <?php, <? is a short version, not all servers support it.
     
    krakjoe, Jun 9, 2007 IP
  3. cancer10

    cancer10 Guest

    Messages:
    364
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    How do I enable it?

    PS: I have the remote desktop access to my server.
     
    cancer10, Jun 9, 2007 IP
  4. cfguy

    cfguy Guest

    Messages:
    12
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    you need to locate and edit your php.ini file on the server.
     
    cfguy, Jun 9, 2007 IP
  5. InFloW

    InFloW Peon

    Messages:
    1,488
    Likes Received:
    39
    Best Answers:
    0
    Trophy Points:
    0
    #5

    There should be a short_open_tag in your PHP.ini and as of right now it's set to Off I imagine. So just set it to On and restart the web server and you should be able to use <? . Of course <? is a deprecated feature is it that hard to type <?php ? :p
     
    InFloW, Jun 9, 2007 IP
  6. ansi

    ansi Well-Known Member

    Messages:
    1,483
    Likes Received:
    65
    Best Answers:
    0
    Trophy Points:
    100
    #6
    i would recommend sticking with <?php personally as it'll work on any server. you don't have to worry about short tags being enabled or not. and plus that, it's only 3 extra characters. and thank god for asp style tags <% %> disappearing in php6 :)
     
    ansi, Jun 9, 2007 IP
  7. coderbari

    coderbari Well-Known Member

    Messages:
    3,168
    Likes Received:
    193
    Best Answers:
    0
    Trophy Points:
    135
    #7
    yes <?php should be used.there is not much work need to write those 3 letters(php) but it will save you u from lot of problem
     
    coderbari, Jun 9, 2007 IP