Home  >  Article  >  Backend Development  >  Alternative syntax for process control in php process control

Alternative syntax for process control in php process control

不言
不言Original
2018-05-04 09:31:301643browse

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

php process control else

php flow control if statement

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn