Is it now safe to use short PHP echo tags?

Now completely and completely safe to use.

<?=$var ?> 

instead

 <?php echo $var; ?> 
+7
source share
6 answers

I would not use the words “completely” and “completely”, but with PHP5.4, “short open and echo” -syntax is part of the kernel and therefore always available. Recall that I am only talking about <?= ?> , And not about the "normal" short open tags <? ?> <? ?> .

+12
source

Yes Starting March 01, 2012 with PHP 5.4.0 you can use a short tag . From php 5.4 change log ,

 <?= is now always available regardless of the short_open_tag setting. 

It was a general improvement.

So, if you have PHP 5.4, you can use the <?= Syntax.

+5
source

Yes. There is no real problem using <?=$var?> , But if you want to fully prepare for a host that does not have this, you can write it with the full operator.

You can usually enable this feature even if it is disabled.

+2
source

It’s always best to use a regular <?php tag. Thus, you are sure that your scripts are always compatible with any PHP installation, regardless of the PHP or php.ini settings.

More importantly, if you are developing code intended for sharing, such as a library.

0
source

ref: http://php.net/ChangeLog.php#5.4.32

"short open tag is now always available regardless of short_open_tagsetting"

0
source

Yes. Starting with PHP 5.4, echo tags are always enabled if your host does not disable them.

-2
source

All Articles