This is a tasty question oh, for, while, doing while the difference I think you should understand the three usages and the difference after you look carefully.
Do...while statement
A do-while statement should have the following format:
do {
statements;
while (condition);
<?php
$a = 1;
do {
$a + +;
}while ($a <1);
echo $a;
?>
Output is 2
Does while it executes once, regardless of whether the condition is set up, to see the implementation.
While statement
A while statement should have the following format
while (condition) {
statements;
}
An empty while statement should have the following format:
while (condition);
Look at a while implementation
<?php
$a = 1;
while ($a <1) $a + +;
echo $a;
?>
Output is 1
NOTE: The while statement must be conditional to true to perform the contents of the while inside, for and while is the same
For statement
A For statement should have the following format:
for (initialization; condition update) {
statements;
}
An empty for statement (all work in initialization, conditional judgment, UPDATE clause completion) should have the following format:
for (initialization; condition; update);
When using commas in initialization or update clauses of a for statement, avoid using more than three variables, resulting in increased complexity. If necessary, separate statements can be used before the for loop (for initialization clauses) or at the end of the For loop (for UPDATE clauses).
For implementation
<?php
$a = 1;
For ($a =1 $a <1; $a + +) {
$a + +;
}
echo $a;
?>
Output is 1