phpfunctionechopageload

PHP echo vs PHP short echo tags


Are they equal in safeness? I was informed that using

<?=$function_here?>

was less safe, and that it slows down page load times. I am strictly biased to using echo.

What are the advantages/disadvantages?


Solution

  • http://php.net/manual/en/language.basic-syntax.phpmode.php states:

    Starting with PHP 5.4, short echo tag is always recognized and valid, regardless of the short_open_tag setting.

    short_open_tag Off or On doesn't matter anymore.

    So now you can, without concern, put tags like this in your templates:

        <?= (($test) ? "val1" : "val2") ?>
    

    It is official now, the "short echo tag" is something very different than the "short tag".