Home  >  Article  >  What are the flow control statements?

What are the flow control statements?

hzc
hzcOriginal
2020-06-24 13:46:467348browse

What are the flow control statements?

Flow control statements are divided into three parts: sequence, selection and loop.

Sequential statements are executed from top to bottom.

Loop statements There are three types of for, while and do...while. The loop variable of for is in the loop and will be recycled after the loop ends, saving space but cannot be used again. The while loop variable is outside the loop and can be called again after the loop ends. The do...while loop will be executed once regardless of whether the condition is true or not. for and while will execute the loop body only when the condition is met.

The selection statement is executed using switch....case...default. After case and default, there is a statement body and break. When the conditions are met, it will jump to the corresponding case statement body and directly break to end the loop. The default statement will be executed when the conditions are not met.

The above is the detailed content of What are the flow control statements?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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