tags:

views:

448

answers:

7

Is there any particular reason to use one over the other? I personally tend to use the latter, as it just seems to flow better to me.

+12  A: 

They do the same thing, the <?= is just called the short tag and is shorthand for <?php echo. You have to make sure the short tags are enabled to use the <?= notation.

Brian Fisher
It's also not compatible with XML-based docs (like Xhtml), since XML requires '<?' for it's own use. Long tags '<?php' are compatible, and highly recommended for portability.
Alister Bulman
As the php.ini.dist files says: "NOTE: Using short tags should be avoided when developing applications or libraries that are meant for redistribution, or deployment on PHP servers which are not under your control, because short tags may not be supported on the target server....."
Alister Bulman
+3  A: 

As far as I know, they are functionally equivalent except the second can be disabled in configurations so isn't as portable.

Rob Prouse
+1  A: 
ohnoes
The correct answer imo. Though a quote could be posted in the text instead of just a link.
OIS
OIS, as you wish.
ohnoes
A: 

The shorthand is clearer. It says, with as few words possible:

"Here, an expressions is echoed and nothing else is going on."

PEZ
A: 

Short tags are disabled on a significant amount of php installation so I never use

<?=$my_var?> // Bad Portability

<?php echo $my_var; ?> // Good Portability!
Mike B
A: 

I would assume that <?php= $session_id; ?> works fine, and does not have the issue of portability.

A: 

Just an addon question. I've read a few years ago that using <? and ?> is not recommended due to security issues. Is this correct?

rebellion