PHP Syntax and Semantics - Alternative Syntax For Control Structures

Alternative Syntax For Control Structures

PHP offers an alternative syntax using colons rather than the standard curly-brace syntax (of "{...}"). This syntax affects the following control structures: if, while, for, foreach, and switch. The syntax varies only slightly from the curly-brace syntax. In each case the opening brace ({) is replaced with a colon (:) and the close brace is replaced with endif;, endwhile;, endfor;, endforeach;, or endswitch;, respectively. Mixing syntax styles within the same control block is not supported. An example of the syntax for an if/elseif statement is as follows:

if (condition) : // code here elseif (condition) : // code here else : // code here endif;

Read more about this topic:  PHP Syntax And Semantics

Famous quotes containing the words alternative, control and/or structures:

    “A mental disease has swept the planet: banalization.... Presented with the alternative of love or a garbage disposal unit, young people of all countries have chosen the garbage disposal unit.”
    —Ivan Chtcheglov (b. 1934)

    “Our culture still holds mothers almost exclusively responsible when things go wrong with the kids. Sensing this ultimate accountability, women are understandably reluctant to give up control or veto power. If the finger of blame was eventually going to point in your direction, wouldn’t you be?”
    —Ron Taffel (20th century)

    “It is clear that all verbal structures with meaning are verbal imitations of that elusive psychological and physiological process known as thought, a process stumbling through emotional entanglements, sudden irrational convictions, involuntary gleams of insight, rationalized prejudices, and blocks of panic and inertia, finally to reach a completely incommunicable intuition.”
    —Northrop Frye (b. 1912)