Home > Article > Backend Development > Alternative syntax for process control in php process control
This article mainly introduces the alternative syntax of process control in PHP process control. It has a certain reference value. Now I share it with you. Friends in need can refer to it.
This article is tried for Basiclearners, experts please close this page
It takes 3 minutes to read this article, it’s hard to understand because it’s hard to explain
echo "a equals 5"; echo "..."; elseif ($a == 6): echo "a equals 6"; echo "!!!"; else: echo "a is neither 5 nor 6"; endif; ?>
Note:
Mixing the two syntaxes within the same control block is not supported.
Warning
Any output (including spaces) between switch and the first case will result in a syntax error. For example, this is invalid:
<?php switch ($foo): ?> <?php case 1: ?> ... <?php endswitch ?>
But this is valid, because the newline character after switch is considered to be part of the closing tag ?>, so there cannot be any output between switch and case:
<?php switch ($foo): ?> <?php case 1: ?> ... <?php endswitch ?>
Related recommendations:
php process control elseif/else if
The above is the detailed content of Alternative syntax for process control in php process control. For more information, please follow other related articles on the PHP Chinese website!