addressalign-toparrow-leftarrow-leftarrow-right-10x10arrow-rightbackbellblockcalendarcameraccwcheckchevron-downchevron-leftchevron-rightchevron-small-downchevron-small-leftchevron-small-rightchevron-small-upchevron-upcircle-with-checkcircle-with-crosscircle-with-pluscontroller-playcredit-cardcrossdots-three-verticaleditemptyheartexporteye-with-lineeyefacebookfolderfullheartglobe--smallglobegmailgooglegroupshelp-with-circleimageimagesinstagramFill 1languagelaunch-new-window--smalllight-bulblightning-boltlinklocation-pinlockm-swarmSearchmailmediummessagesminusmobilemoremuplabelShape 3 + Rectangle 1ShapeoutlookpersonJoin Group on CardStartprice-ribbonprintShapeShapeShapeShapeImported LayersImported LayersImported Layersshieldstar-shapestartickettrashtriangle-downtriangle-uptwitteruserwarningyahooyoutube

Re: [php-49] Using colon instead of curly-braces { } with conditionals

From: David M.
Sent on: Thursday, March 19, 2009, 6:23 PM
Thanks for tapping the iPhone -- that's an interesting scenario to use colons in!!

David

--- On Thu, 3/19/09, m. <[address removed]> wrote:
From: m. <[address removed]>
Subject: Re: [php-49] Using colon instead of curly-braces { } with conditionals
To: [address removed]
Date: Thursday, March 19, 2009, 6:01 PM

As expressed in the comments the colon syntax best fits when mixing HTML and PHP and control strucutres.

I don't know if this is the most efficient way to do this but I often use:

<?php if($some_array){ foreach($array as $k => $v): ?>
<div>
  <h1>some title</h1>
  <p><?php echo $k?>: <?php echo $v?></p>
</div>
<?php endforeach;}?>

(wow that was a pain to tap out on an iPhone)
  
On Mar 19, 2009, at 5:43 PM, David Malouf <[address removed]> wrote:

Came across this blog entry and it got me wondering...
http://www.codediesel.com/php/the-benefits-of-the-colon-syntax-for-control-structures/

The premise of the article is that when code gets big and nested, using curly-braces can get troublesome.  Instead, PHP can handle a colon followed by an END__

For example:
    if ($something == 'true') :
        $aBunchOfCodeHere = 'yes';
    endif;

Using NetBeans (like Eclipse and I'm assuming other IDEs) means I can 'see' what conditional/line each closing-curly-brace  }   is associated with.

Since I'm curious, though, I'm wondering if there is ever a time when any of y'all use the colon method?


David





--
Please Note: If you hit "REPLY", your message will be sent to everyone on this mailing list ([address removed])
This message was sent by David Malouf ([address removed]) from The Seattle PHP Meetup Group.
To learn more about David Malouf, visit his/her member profile
To unsubscribe or to update your mailing list settings, click here

Meetup Support: [address removed]
632 Broadway, New York, NY 10012 USA




--
Please Note: If you hit "REPLY", your message will be sent to everyone on this mailing list ([address removed])
This message was sent by m. ([address removed]) from The Seattle PHP Meetup Group.
To learn more about m., visit his/her member profile
To unsubscribe or to update your mailing list settings, click here

Meetup Support: [address removed]
632 Broadway, New York, NY 10012 USA

People in this
group are also in: