» Alternate Syntaxes by falsepride |
|
(Login to remove green text ads)
PHP has an alternative syntax for some of its control structures(if, while, for, foreach, and switch). The basic form of the alternate syntax is to change the opening brace({) to a colon (:) and the closing brace(}) to endif;, endwhile;, endfor;, endforeach;, or endswitch.
Example:
PHP Code:
<?php
if ($number == 1):
echo "number equals 1";
echo "...";
elseif ($number == 2):
echo "number equals 2";
echo "!!!";
else:
echo "number is neither 1 nor 2";
endif;
?>
|
|