PHPDeveloper.orghttp://www.phpdeveloper.org
Up-to-the Minute PHP News, views and communityen-usTue, 31 Mar 2015 15:49:48 -050030http://www.phpdeveloper.org/news/11744http://www.phpdeveloper.org/news/11744
In this recent post to his CodeDiesel.com blog, Sameer is promoting the use of colons in control structures over curly braces.

PHP offers a alternative syntax for some of its control structures- if, while, for, foreach, and switch, where you change the opening brace to a colon (:) and the closing brace to endif;, endwhile;, endfor;, endforeach;, or endswitch;, respectively. [...] With the colon syntax you just have to match a '˜if' with a '˜endif' or a '˜for' with a '˜endfor'. When you are mixing HTML with PHP in web pages the code can become quite dense and confusing if it uses a lot of braces.

An example is included showing its use in "if" and "white" statements. With most editors and IDEs supporting brace matching and code folding, this is less of an issue, but it can help make for cleaner code.