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:

    Education must, then, be not only a transmission of culture but also a provider of alternative views of the world and a strengthener of the will to explore them.
    Jerome S. Bruner (20th century)

    The basic tool for the manipulation of reality is the manipulation of words. If you can control the meaning of words, you can control the people who must use the words.
    Philip K. Dick (1928–1982)

    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)