php flow control statements include: 1. The process of executing sequential statements is from top to bottom, from left to right, without jumping; 2. The selection statement can only be executed if it meets the conditions, and judgment is required; 3 , There are three main types of loop control statements: while, for, and do while.
php process control statements include:
PHP has three major process control statements, namely sequence statement and selection statement ,loop statement.
1. Sequential statementsThe execution process is from top to bottom, from left to right, without jumping.
2. 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(条件){ 执行语句 }
2.
if(条件) { 执行语句 } else { 执行语句 }
3.
if(条件){ 执行语句 }else if (条件){ 执行语句 }else{ 执行语句 }
4.
switch(条件) { case 1:语句;break; case 2:语句;break; case 3:语句;break; ………… default:语句;break; }
3. Loop control statement There are three main types: while
, for
, do while
. To put it bluntly, it means repeated execution. But you need to understand how many times it is executed.
1.
初始值,如$a=5 while(条件){ 循环体; 步增值; }
2.
for(初始值;条件;步增值){ 循环体 }
3.
初始值; do{ 循环题; 步增值; }while(条件);
In PHP, there is a special loop. Cyclic associative array
4.
foreach(数值 as $key=>$val){ 循环题; }
Related learning recommendations:PHP programming from entry to proficiency
The above is the detailed content of What are the PHP process controls?. For more information, please follow other related articles on the PHP Chinese website!