Why are "echo" short tags permanently enabled as of PHP 5.4?
Short open tags are not always enabled since PHP 5.4. The documentation talks about the short echo tags. Which is a different thing. (short open tags are <?
style tags, short echo tags are <?=
style tags, for echo-ing).
Then why are they enabled by default now? Well, there are a lot of scripts out there, where it benefits to use <?= $somevar ?>
instead of <?php echo $somevar ?>
. And because the short echo tags aren't as bad as the short open tags, they chose to always enable the short echo tags. Because now developers (of frameworks and CMS-es) can count on them (or rather, when PHP 5.4 becomes mainstream).
However, the short open tags are still influenced by the short_open_tag
setting in your php.ini.
Only short echo tag (<?=
) is enabled permanently, not short open tags (<?
).
It's because short echo tag is really handy when you're creating HTML templates (or any other view templates) and without that you have to write a lot more (like <?php echo $var; ?>
instead of just <?= $var ?>
).