View Single Post
02-19-2007, 12:40 AM
#12
Salathe is offline Salathe
Salathe's Avatar
Status: Community Archaeologist
Join date: Jul 2004
Location: Scotland
Expertise: Software Development
Software: vim, PHP
 
Posts: 3,820
iTrader: 25 / 100%
 

Salathe will become famous soon enough

Send a message via MSN to Salathe

  Old

This topic is based entirely on Ali's own personal opinion. It's not "bad" code use use the curly braces around single statements, it is just that Ali doesn't like that style.

The advantages and disadvantages of omitting the braces are, in my opinion, negligible and it's really just a matter of sticking with how you want to do it.

PHP Code:
// This?
if (true === $condition)
    
$is_true true;
else
    
$is_true false;

//or this?  OMG ONE MORE LINE!
if (true === $condition) {
    
$is_true true;
} else {
    
$is_true false;
}

// or this, with ternary operator
$is_true = (true === $condition) ? true false;

// or lazy boolean, with ternary
$is_true $condition true false
IMO, if it aids readability of the code then why on earth NOT use the curly braces?