Hi, I'm not sure of any performance difference.
I think curlys should be used in most situations for the reasons described above, but using the colon syntax is very useful in templates. symfony uses the colon syntax in it's templates. - Cam On Tue, Jan 27, 2009 at 5:51 PM, Mike Cochrane <[email protected]>wrote: > > Hi Rowan, > > I'm not aware of any performance difference - i would expect it would > only be on bytecode compilation so a cache like APC would remove that. > > Curly makes for easier collapsing of code in your editor and most > editors will show you matching braces so you can match them and see non > matching ones. If you're working on almost any php opensource project > there will be a strong preference/requirement for curly in the coding > standards so I would recommend this in any php code. Colon is nice and > easy to read in templates where it's mixed with html. > > From Drupal: > > You are strongly encouraged to always use curly braces even in > situations where they are technically optional. Having them > increases readability and decreases the likelihood of logic errors > being introduced when new lines are added. > http://drupal.org/node/318 > > Which appears to be taken from the PEAR Coding Standards - > http://pear.php.net/manual/en/standards.control.php > > Zend refers to the use of braces only - > > http://framework.zend.com/manual/en/coding-standard.coding-style.html#coding-standard.coding-style.control-statements > The Horde Application Frameworks says "Do not omit the curly braces > under any circumstance." - > http://www.horde.org/horde/docs/?f=CODING_STANDARDS.html > > But if it's just for you then do what works for you :-) > > - Mike > > > On 27/01/2009 16:21, Stig Manning wrote: > > Hi Rowan, > > > > No difference, but : makes for better readability when templating with > PHP. > > It is easy to see where the foreach ends "endforeach" rather than trying > > to find the matching } symbol. > > > > Cheers, > > Stig > > > > Rowan wrote: > > > >> Hi Guys > >> > >> Just wondering - is there any difference (performance or otherwise) > >> between using a Colon or Curly Bracket in the following example: > >> > >> <?php foreach($zings as $zang): ?> > >> <td><?php //some code ?></td> > >> <?php endforeach; ?> > >> > >> OR > >> > >> <?php foreach($zings as $zang){ ?> > >> <td><?php //some code ?></td> > >> <?php } ?> > >> > >> Cheers, > >> Rowan > >> > >> > >> > > > > > > > > > > > > -- > Mike Cochrane > Web Team Leader > > gardyneHOLT - design partners > 18 Beresford Square Newton > PO Box 3340 Auckland New Zealand > p +64 9 300 3155 f +64 9 302 3349 m 021 545 565 > skype gardyneholt_mikec > www.gardyneholt.co.nz > > DISCLAIMER: This electronic message, together with any attachments, was > created solely for the use of the intended recipient(s), and may be > confidential. Views expressed may be those of the individual sender and are > not necessarily endorsed by gardyneHOLT. If you are not the intended > recipient, please advise us by return e-mail that you have received the > message in error and then delete it. Do not copy, disclose or use the > contents in any way. > > > > > --~--~---------~--~----~------------~-------~--~----~ NZ PHP Users Group: http://groups.google.com/group/nzphpug To post, send email to [email protected] To unsubscribe, send email to [email protected] -~----------~----~----~----~------~----~------~--~---
