Any one knows what it exactly means in php <?=

Discussion in 'PHP' started by sure, Mar 17, 2009.

  1. #1
    Hi all,
    I am new to php. I saw this in some web site forum. What is it exactly means. Any one knows please let me know.

    Thanking you
    sure
     
    sure, Mar 17, 2009 IP
  2. crivion

    crivion Notable Member

    Messages:
    1,669
    Likes Received:
    45
    Best Answers:
    0
    Trophy Points:
    210
    Digital Goods:
    3
    #2
    yeah it meens <?php echo
     
    crivion, Mar 17, 2009 IP
  3. [x[x]x]

    [x[x]x] Peon

    Messages:
    813
    Likes Received:
    30
    Best Answers:
    0
    Trophy Points:
    0
    #3
    yes and this method will only work for single lined scripts, such as:

    <?= "hello world" ?>
    PHP:
     
    [x[x]x], Mar 17, 2009 IP
  4. SmallPotatoes

    SmallPotatoes Peon

    Messages:
    1,321
    Likes Received:
    41
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Huh? It will work anywhere.
     
    SmallPotatoes, Mar 17, 2009 IP
  5. Topunit

    Topunit Peon

    Messages:
    95
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #5
    <?="Text."?> is a shortcut for <?php echo "Text."; ?>.
     
    Topunit, Mar 17, 2009 IP
  6. InFloW

    InFloW Peon

    Messages:
    1,488
    Likes Received:
    39
    Best Answers:
    0
    Trophy Points:
    0
    #6
    It's very useful when you're dealing with php templating. It makes doing templates and printing our variables a lot easier in terms of number of characters you need to type in. It also looks cleaner in my opinion.
     
    InFloW, Mar 17, 2009 IP
  7. joebert

    joebert Well-Known Member

    Messages:
    2,150
    Likes Received:
    88
    Best Answers:
    0
    Trophy Points:
    145
    #7
    That syntax drives me nuts.

    It takes me soo much longer to work out bugs when I have HTML with PHP in it VS PHP that loads XML/HTML and saves cached pages.

    Especially when you start getting stuff like
    <?php if(true){ ?>
    <div>...</div>
    <?php } ?>
    Code (markup):
    Not to mention it screws my snippets and syntax highlighting in gedit up something fierce.
     
    joebert, Mar 17, 2009 IP
  8. SmallPotatoes

    SmallPotatoes Peon

    Messages:
    1,321
    Likes Received:
    41
    Best Answers:
    0
    Trophy Points:
    0
    #8
    100% agree.
     
    SmallPotatoes, Mar 17, 2009 IP
  9. Brooke I. Yates

    Brooke I. Yates Banned

    Messages:
    70
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #9
    You should not use it as is not standard. Use
    as it's standard and would work fine on many invironments.
     
    Brooke I. Yates, Mar 18, 2009 IP
  10. Topunit

    Topunit Peon

    Messages:
    95
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #10
    Why is it not standard? They should both work on any enviroment assuming short-tags are enabled, which they are by default.
     
    Topunit, Mar 18, 2009 IP
  11. abmathur

    abmathur Member

    Messages:
    211
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    30
    #11
    If you are integrating php with html than only use it else simple echo is good; although its recommended to use <?php since only <? or <?= might not work in some environments (many Win Versions).
     
    abmathur, Mar 18, 2009 IP
  12. jazzcho

    jazzcho Peon

    Messages:
    326
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #12
    Do not use the short syntax. Alway use the long one. Not all php servers have it enabled.
     
    jazzcho, Mar 27, 2009 IP
  13. bhagwant.banger

    bhagwant.banger Active Member

    Messages:
    99
    Likes Received:
    6
    Best Answers:
    1
    Trophy Points:
    60
    #13
    They are short tags+echo in php a short cut for <?php echo $something; ?> as <?=$something


    but in order to use them they should be enabled in the php.ini

    Try to avoid them and use the full syntax instead
    eg.,
    <?php ?>
     
    bhagwant.banger, Mar 27, 2009 IP