Reputation: 12320
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.
Upvotes: 6
Views: 1212
Reputation: 6740
Just an addon question. I've read a few years ago that using <?
and ?>
is not recommended due to security issues. Is this correct?
Upvotes: 0
Reputation:
I would assume that <?php= $session_id; ?>
works fine, and does not have the issue of portability.
Upvotes: 0
Reputation: 32155
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!
Upvotes: 0
Reputation: 5612
short_open_tag
booleanTells whether the short form ( ) of PHP's open tag should be allowed. If you want to use PHP in combination with XML, you can disable this option in order to use inline. Otherwise, you can print it with PHP, for example: . Also if disabled, you must use the long form of the PHP open tag ( ).
Note: This directive also affects the shorthand
Upvotes: 1
Reputation: 17004
The shorthand is clearer. It says, with as few words possible:
"Here, an expressions is echoed and nothing else is going on."
Upvotes: 0
Reputation: 22647
As far as I know, they are functionally equivalent except the second can be disabled in configurations so isn't as portable.
Upvotes: 3
Reputation: 23989
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.
Upvotes: 13