The last article introduced you to "Implementation steps - single branch structure (with source code)". This article continues to introduce you to the double branch structure, so let us continue to learn! ! ! Let's Go!!!
Double branch structure:
Format 1:
if (conditional statement)
A PHP statement
else
A PHP statement
The double branch is to add an else branch based on the single branch
If the conditional expression turns out to be true, the first PHP after if will be executed Code
If the conditional expression result is false, the first day PHP code after else will be executed
The code after if is called if interval or true interval
The code after else is called else interval or false interval
Format 2:
if (conditional expression) {
One PHP statement
Two PHP statements
...
}else{
One PHP statement
Two PHP statements
...
}
## If used, generally use the {} format version, because {} is more readable and less likely to be confused, and the functions of format 2 already include the functions of format 1. A PHP statement can be written within {}.
We take the code as an example for the specific format. The code is as follows:'; else echo '看见他很不爽
'; echo '你懂的?
'; //格式2 $pome = '你知道他是谁吗'; if($pome == '你知道他是谁吗') { echo '风光的背后不是沧桑,是肮脏
'; echo '你身边有奇葩的人吗
'; }else{ echo '没办法,碰到就忍着吧,昂!
'; } ?>
PHP video tutorial》
The above is the detailed content of Detailed explanation and examples - double branch structure (with source code). For more information, please follow other related articles on the PHP Chinese website!