PHP process control do-while

不言
Release: 2023-03-25 10:54:01
Original
1674 people have browsed it

This article mainly introduces the do-while of PHP process control, which has certain reference value. Now I share it with everyone. Friends in need can refer to it

This article is for basic useLearners, experts please close this page

Read this article for 3 minutes, it’s hard to understand those who have difficulty?

(PHP 4 , PHP 5, PHP 7)

The do-while loop is very similar to the while loop, except that the value of the expression is checked at the end of each loop instead of at the beginning. The main difference from a normal while loop

is that the do-while loop statement is guaranteed to be executed once (the truth value of the expression is checked after each loop), however in a normal while loop

is not necessarily true (the truth value of the expression is checked at the beginning of the loop, if it is

FALSEat the beginning, the entire loop terminates immediately).

There is only one syntax for do-while loops:

 0); ?>
Copy after login

The above loop will run exactly once, because after the first loop, when the truth value of the expression is checked, its value isFALSE(not greater than 0) causes the loop to terminate.

Experienced C language users may be familiar with a different do-while loop usage, which is to put the statement inside do-while(0) and use thebreakstatement inside the loop. End the execution loop. The following code snippet demonstrates this method:

Copy after login

Related recommendations:

php process control while

php process control process control Alternative syntax for

The above is the detailed content of PHP process control do-while. 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
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!