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:

    Our mother gives us our earliest lessons in love—and its partner, hate. Our father—our “second other”Melaborates on them. Offering us an alternative to the mother-baby relationship . . . presenting a masculine model which can supplement and contrast with the feminine. And providing us with further and perhaps quite different meanings of lovable and loving and being loved.
    Judith Viorst (20th century)

    The inability to control our children’s behavior feels the same as not being able to control it in ourselves. And the fact is that primitive behavior in children does unleash primitive behavior in mothers. That’s what frightens mothers most. For young children, even when out of control, do not have the power to destroy their mothers, but mothers who are out of control feel that they may destroy their children.
    Elaine Heffner (20th century)

    The philosopher believes that the value of his philosophy lies in its totality, in its structure: posterity discovers it in the stones with which he built and with which other structures are subsequently built that are frequently better—and so, in the fact that that structure can be demolished and yet still possess value as material.
    Friedrich Nietzsche (1844–1900)