PHP do while loop statement with syntax and example
If specified condition is true, loop through block of code once and then repeat again and again. Syntax of PHP do while loop:
1 2 3 | do { code to be executed; } while (condition); |
Example:
1 2 3 4 5 6 7 | <?php $a= 11; do { echo "The number is: $a <br/>"; $a++; } while ($a <= 3); ?> |
Result:
1 2 3 | The number is: 11 The number is: 12 The number is: 13 |
Do while loop is known as exit control loop because it check the condition at last(on exit). Do while loop executes at least once when if condition … Read more