Do you use the short open tag (<?=) in >= PHP 5.4

Hi all,

Prior to PHP 5.4, all PHP experts say that we should not use the short open tag (for various reasons), but since PHP 5.4, it is enabled by default again.

So I wanted to know if you are going to keep the “good practice” and does not use or otherwise you will use in your new projects?

I await your feedback!

Enabled or not, I’ve never used short tags and I see no compelling reason to start using them now. Why? To save a few keystrokes?

Short tag is less portable and not recommended.

I dont, as a software developer I am creating a script used by primarily users running free/shared webhosts, cant assume most of them enable short tags.

I don’t use short tags either. I just don’t see the purpose. <? versus <?php is all you are talking about…

It makes sense only in views/templates so instead of


<div>
    <ul class="nav">
        <li><?php echo $nav_link[ 'home' ]; ?></liv>
        <li><?php echo $nav_link[ 'about' ]; ?></liv>
        <li><?php echo $nav_link[ 'contact' ]; ?></liv>
    </ul>
</div>

you can do:


<div>
    <ul class="nav">
        <li><?= $nav_link[ 'home' ]; ?></liv>
        <li><?= $nav_link[ 'about' ]; ?></liv>
        <li><?= $nav_link[ 'contact' ]; ?></liv>
    </ul>
</div>

What doesn’t make sense to me is that while a number of people just rave on about how short tags are evil, they have no issues using similar shorthand when provided by a template engine so they can do something like:


<div>
    <ul class="nav">
        <li>{{ nav_link[ 'home' ] }}</liv>
        <li>{{ nav_link[ 'about' ] }}</liv>
        <li>{{ nav_link[ 'contact' ] }}</liv>
    </ul>
</div>

Myself included, everyone tries to shorten css. But css is handled client side. Php server side. I would guess server side is faster so shortening has less effect.

In the title you are showing short echo tags not short tags, short echo tags (new classification in 5.4) are always enabled.
http://php.net/manual/en/language.basic-syntax.phpmode.php

"Note:

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

I always use the short <?php ?> version of the PHP tags rather than the longer <script language=“php”> </script> version.

LOL, nobody uses the <script language=“php”> </script> tag!