Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New Coder
    Join Date
    Nov 2010
    Location
    California
    Posts
    42
    Thanks
    6
    Thanked 2 Times in 2 Posts

    Is it mandatory to use

    When coding in PHP, is there a difference between the following opening tags?

    PHP Code:
    <?php

    echo This is a program

    ?>
    and this one

    PHP Code:
    <?

    echo This is a program

    ?>
    -PM-

  • #2
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,456
    Thanks
    8
    Thanked 1,084 Times in 1,075 Posts
    It's called the "short open tag" ....

    Defined in the PHP .ini file:

    http://php.net/manual/en/ini.core.php

    Default is that the short tag is allowed.

  • #3
    Senior Coder
    Join Date
    Jul 2009
    Location
    South Yorkshire, England
    Posts
    2,318
    Thanks
    6
    Thanked 304 Times in 303 Posts
    Yes. The former type is guaranteed to work on any system whilst the latter is not.

  • #4
    New Coder
    Join Date
    Nov 2010
    Location
    California
    Posts
    42
    Thanks
    6
    Thanked 2 Times in 2 Posts
    Oh, okay thanks. Nice to know

    -PM-

  • #5
    Senior Coder
    Join Date
    Jun 2008
    Location
    New Jersey
    Posts
    2,535
    Thanks
    45
    Thanked 259 Times in 256 Posts
    If the latter works, you also have access to what is basically a short echo:

    PHP Code:
    <?=$name?>
    will echo the value of $name.


  •  

    Posting Permissions

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