What's the use of <?= ?> tags in PHP?

This question already has an answer here:

  • Reference — What does this symbol mean in PHP? 18 answers
  • What does '<?=' mean in PHP? 8 answers

  • <?= this is the short tag in php.

    Its equivalent to <?php echo

    Your code is executed as

    <?php
    echo $a = 10;
    echo $a . "n";
    

    <?= is replaced with <?php echo

    So you are getting 10 twice in output.


    <?php echo 'whatever'; ?>
    <? echo 'whatever'; ?>
    

    and

    <?='whatever';?>
    

    are the same thing.

    Just make sure you have short_open_tag = On in php.ini .

    It basically saves you from typing as much.

    链接地址: http://www.djcxy.com/p/59344.html

    上一篇: 在PHP中使用<?= $ foo?>

    下一篇: PHP中使用<?=?>标记有什么用?