Home > Backend Development > PHP Problem > What are the PHP process controls?

What are the PHP process controls?

coldplay.xixi
Release: 2023-03-02 09:16:01
Original
3204 people have browsed it

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.

What are the PHP process controls?

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(条件){
    执行语句
     }
Copy after login

2.

if(条件) {
      执行语句
       } else {
      执行语句
         }
Copy after login

3.

if(条件){
      执行语句
       }else if (条件){
         执行语句
       }else{
        执行语句
       }
Copy after login

4.

switch(条件) {
         case 1:语句;break;
       case 2:语句;break;
       case 3:语句;break;
           …………
         default:语句;break;
                    }
Copy after login

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(条件){
   循环体;
   步增值; 
   }
Copy after login

2.

for(初始值;条件;步增值){
   循环体
   }
Copy after login

3.

初始值;
do{
循环题;
步增值;
}while(条件);
Copy after login

In PHP, there is a special loop. Cyclic associative array

4.

foreach(数值 as $key=>$val){
循环题;
}
Copy after login

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!

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