Blog

December 14, 2010

Lose the brackets

For short conditional logic, you don't need the brackets! For a simple succinct if statement, you can lose the brackets. For example, you may have a variable that needs to be set to another value when empty. This is a pretty simple if statement:   if ( empty($var) ) { $var = 'another value'; }   However, all these extra brackets can unnecessarily bulk up your code. You can simplify that if statement to   if ( empty($var) ) $var = 'ano.... read more

Posted in php | Post Comment | 2