Page 1 of 1
<?=$variable?>
Posted: Thu Sep 24, 2009 11:51 am
by fluvly
I found this syntax in a code:
They seem like the php start and end tags, but what does the "equal" sign do? I tried replacing it with:
It didn't work. Thanks to anyone who can help me.
Re: <?=$variable?>
Posted: Thu Sep 24, 2009 12:18 pm
by watson516
<?=$variable?> is a short form of <?php echo $variable; ?>
Don't use it.
Re: <?=$variable?>
Posted: Thu Sep 24, 2009 2:28 pm
by jackpf
watson516 wrote:Don't use it.
Why not?
Re: <?=$variable?>
Posted: Thu Sep 24, 2009 2:31 pm
by Mirge
watson516 wrote:<?=$variable?> is a short form of <?php echo $variable; ?>
Don't use it.
That begs for the next question, "why not?"
It can cause confusion with XML, and some people don't have access to PHP configuration to enable short tags. See:
http://stackoverflow.com/questions/2006 ... ble-to-use
Now, from my own personal experience... I've yet to run into a problem using short tags. Every client I've ever had either had short tags enabled, or had access to configuration to enable it. Keep in mind, the software I write for my clients is designed to run on THEIR server(s) only. It's not distributed software.
For software that will be distributed (ie: sold), I would recommend using the full version (ie: <?php echo $foo; ?>) over short tags purely for compatibility. If you are re-selling software that uses short tags, expect emails asking why things aren't working...
EDIT:
jackpf wrote:watson516 wrote:Don't use it.
Why not?
Told ya!

Re: <?=$variable?>
Posted: Thu Sep 24, 2009 2:50 pm
by jackpf
Exactly. If it's running on your own server where you have access to its settings, then there's no reason not to use short tags. I find them extremely useful for templates. Saves a lot of repetitive typing.
Everyone says not to use them simply because they've been told not to. It doesn't necessarily make them bad though...