unsure about syntax i havent encountered before?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
eoinahern
Forum Newbie
Posts: 8
Joined: Tue Sep 24, 2013 3:30 pm

unsure about syntax i havent encountered before?

Post 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>
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: unsure about syntax i havent encountered before?

Post 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.
(#10850)
eoinahern
Forum Newbie
Posts: 8
Joined: Tue Sep 24, 2013 3:30 pm

Re: unsure about syntax i havent encountered before?

Post by eoinahern »

so basically ALL its doing is echoing out the variable. i dont like the look of that myself either to be honest.
User avatar
AbraCadaver
DevNet Master
Posts: 2572
Joined: Mon Feb 24, 2003 10:12 am
Location: The Republic of Texas
Contact:

Re: unsure about syntax i havent encountered before?

Post 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.
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: unsure about syntax i havent encountered before?

Post 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?>
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: unsure about syntax i havent encountered before?

Post by Celauran »

I use it all the time in my views. It's nice and succinct.
Post Reply