PHP echo vs PHP short tags

2 Answers

Echo is generally just better to use because...

  1. It supports good programming style.
  2. It can't be turned off in php.ini (short tags can be)
  3. Short tags will be removed in PHP 6)

But, they are generally the same. See also:

  1. Are PHP short tags acceptable to use?
  2. How are echo and print different in PHP?

Are they equal in safeness? I was informed that using


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

What are the advantages/disadvantages?

So why don't they just remove the option to turn off short open tag and let it be enabled by default.

This is a VERY dangerous move by PHP. The reason being, if you put your existing code that has short tags in it on a PHP6 server and someone views that page, they will get the raw code downloaded to their browser which you can view. This could seriously kill off 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".