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:

    If you have abandoned one faith, do not abandon all faith. There is always an alternative to the faith we lose. Or is it the same faith under another mask?
    Graham Greene (1904–1991)

    Men who have been raised violently have every reason to believe it is appropriate for them to control others through violence; they feel no compunction over being violent to women, children, and one another.
    Frank Pittman (20th century)

    The American who has been confined, in his own country, to the sight of buildings designed after foreign models, is surprised on entering York Minster or St. Peter’s at Rome, by the feeling that these structures are imitations also,—faint copies of an invisible archetype.
    Ralph Waldo Emerson (1803–1882)