<? vs <?PHP

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Paul Lautman

    #1

    <? vs <?PHP

    I often see the former starting delimiter rather than the latter. Is there
    some rule about where the former can be used?


  • Scott

    #2
    Re: &lt;? vs &lt;?PHP

    On Mon, 2006-04-17 at 00:13 +0100, Paul Lautman wrote:[color=blue]
    > I often see the former starting delimiter rather than the latter. Is there
    > some rule about where the former can be used?
    >
    >[/color]

    There is a setting in your php.ini file called short_open_tags . If it
    is enabled, you can use <? instead of <?php. However, because xml also
    uses the short tag <?, and for compatibility with different servers, it
    is generally recommended that you use the longer <?php tag.



    Scott

    Comment

    • CJ Llewellyn

      #3
      Re: &lt;? vs &lt;?PHP

      On Mon, 17 Apr 2006 00:13:32 +0100, Paul Lautman wrote:
      [color=blue]
      > I often see the former starting delimiter rather than the latter. Is there
      > some rule about where the former can be used?[/color]

      <? is a shortened version of <?php for programmers too lazy to type <?php.
      As <? is configurable in the php.ini file and can be turned off, so it's
      availablity on any given web server is not guarentied. So use it at your
      peril.


      Comment

      • Paul Lautman

        #4
        Re: &lt;? vs &lt;?PHP

        Paul Lautman wrote:[color=blue]
        > I often see the former starting delimiter rather than the latter. Is
        > there some rule about where the former can be used?[/color]

        Thanks CJ & Scott


        Comment

        • Andy Jeffries

          #5
          Re: &lt;? vs &lt;?PHP

          On Mon, 17 Apr 2006 00:13:32 +0100, Paul Lautman wrote:[color=blue]
          > I often see the former starting delimiter rather than the latter. Is there
          > some rule about where the former can be used?[/color]

          While I agree with CJ and Scott, there is a useful construct that can be
          used with short tags (<?) and if your code is running on a server you
          control (as can be the case for a lot of web developers, run clients code
          on servers you control) it can make for easier to read code:

          <?=$foo?>

          is equivalent to:

          <?php echo $foo ?>

          Anyway, just thought I'd add that in.

          Cheers,


          Andy

          --
          Andy Jeffries MBCS CITP ZCE | gPHPEdit Lead Developer
          http://www.gphpedit.org | PHP editor for Gnome 2
          http://www.andyjeffries.co.uk | Personal site and photos

          Comment

          • Locu

            #6
            Re: &lt;? vs &lt;?PHP

            I have heard also that in PHP version 6 the <? will no longer be
            listened for. Which disappoints me becuase I used to always use
            <?=$var?> because it's nice shorthand for the alternative.

            Comment

            Working...