Page 1 of 1

unsure about syntax i havent encountered before?

Posted: Tue Sep 24, 2013 3:37 pm
by eoinahern
seen this in someone elses code i was working on and was sure what is does. creates an error anyway when i run it on wamp. im thinking its a mistake in the code. can anyone shine a light on this for me cheers!

<p><?=$last_key?></p>
<p><?=$lastSeen?></p>

Re: unsure about syntax i havent encountered before?

Posted: Tue Sep 24, 2013 3:49 pm
by Christopher
Those are short tags and are the same as: <?php echo $last; ?> and <?php echo $lastSeen; ?>. I would not recommend using them simply for consistency, but it is really a style choice.

Re: unsure about syntax i havent encountered before?

Posted: Tue Sep 24, 2013 3:53 pm
by eoinahern
so basically ALL its doing is echoing out the variable. i dont like the look of that myself either to be honest.

Re: unsure about syntax i havent encountered before?

Posted: Tue Sep 24, 2013 3:58 pm
by AbraCadaver
eoinahern wrote:so basically ALL its doing is echoing out the variable. i dont like the look of that myself either to be honest.
And it needs to be enabled in the server configuration in order for it to work.

Re: unsure about syntax i havent encountered before?

Posted: Tue Sep 24, 2013 4:24 pm
by requinix
AbraCadaver wrote:And it needs to be enabled in the server configuration in order for it to work.
Not since 5.4: it's available regardless of the short_open_tags setting.

I, for one, like it.

Code: Select all

<?php echo $variable; ?>

Code: Select all

<?=$variable?>

Re: unsure about syntax i havent encountered before?

Posted: Tue Sep 24, 2013 5:12 pm
by Celauran
I use it all the time in my views. It's nice and succinct.