Home > Backend Development > PHP Tutorial > Detailed explanation of the difference between while and do...while in php

Detailed explanation of the difference between while and do...while in php

黄舟
Release: 2023-03-14 14:44:01
Original
1659 people have browsed it

This tutorial will talk about the difference between do while and while loop statements commonly used in PHP programming. While is executed when the condition is true, while do while will be executed at least once. Let’s take a look

do {
}while(条件)
Copy after login

Look at the example of do while.

<?
$a =10;
do {
echo $a;
}while ($a>11)
Copy after login

10 will be output here; and then the loop will terminate, so let’s take a look at the while instance.

$a=10;
while($a>11){
echo $a;
}
Copy after login

There will be no output here, now you understand what it means.

The above is the detailed content of Detailed explanation of the difference between while and do...while in php. 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