The function of php flow control statements is to perform different actions based on different conditions. There are three types of flow control statements in PHP, namely sequence statements, selection statements and loop statements.
The operating environment of this article: windows7 system, PHP7.4 version, DELL G3 computer
The role of php process control statements
The function of php flow control statements is to perform different actions based on different conditions.
There are three major flow control statements in PHP, namely sequence statements, selection statements, and loop statements. Played a big role in programming.
As before, first create a php file to write PHP files.
#The process of executing sequential statements is from top to bottom, from left to right, without jumping.
The selection statement is very interesting. It can be executed only when the conditions are met. There are many kinds of selection statements.
1. if (condition) {
use using using using using through through out through out out through out through ’ ’s' ’ ‐ through ‐ ‐ ‐ ‐ ‐ ‐ to execute the statement
1. if(condition){
##} Else { execute sentence #}
## 3. If (condition) {
## execution sentence } Else if (Condition) { executing sentence } else { execute sentence }## 4.Switch (conditional (conditional conditions ) {
…
default: statement; break;
}
There are three main types of loop control statements: while, for, and do while. To put it bluntly, it means repeated execution. But you need to understand how many times it is executed. 1. Initial value, such as $a=5 while(condition){ Loop body; Step increment;}
2.for (initial value; condition; step increment value){
Loop body
}
3.
Initial value;
do{
Loop question;
Step increment value;
}while(condition);
in PHP , there is a special loop. Loop associative array
4.foreach(value as $key=>$val){
Loop question;
}
Notesdo(){}while loops one more time than whilebreak is to stop the loop, continue is to jump out of this loop, and then loop Recommended learning: "PHP Video Tutorial
"The above is the detailed content of The role of php flow control statements. For more information, please follow other related articles on the PHP Chinese website!