Home > Backend Development > PHP Tutorial > Alternative syntax for process control in php process control

Alternative syntax for process control in php process control

不言
Release: 2023-03-25 10:50:01
Original
1783 people have browsed it

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;
?>
Copy after login

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 ?>
Copy after login

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 ?>
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template