PHP provides an alternative syntax for some control structures:
When compared to the normal syntax, the difference is, that the opening brace is replaced by a colon (
:) and the closing brace is replaced by
endswitch;, respectively. For individual examples, see the topic on alternative syntax for control structures.
if ($a == 42): echo "The answer to life, the universe and everything is 42."; endif;
elseif statements using short-syntax:
if ($a == 5): echo "a equals 5"; elseif ($a == 6): echo "a equals 6"; else: echo "a is neither 5 nor 6"; endif;