Alternative syntax for control structures.

PHP offers an alternative syntax for some of its control structures; namely, if, while, for, foreach, and switch. In each case, the basic form of the alternate syntax is to change the opening brace to a colon (:) and the closing brace to endif;, endwhile;, endfor;, endforeach;, or endswitch;, respectively. (source:

Alternative syntax for control structures for If / Else

Basic True / False Declaration

Conditional Welcome Message

Conditional Items Message

Conditional Error Reporting Level

Conditional Basepath

Nested PHP Shorthand

Leap Year Check

Conditional PHP Redirect


PHP short tags: if/else
Tagged on:             

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.