PHP do while loop statement with syntax and example
If the specified condition is true, loop through the block of code once and then repeat again and again. Syntax
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 an exit control loop because it checks the condition at last(on exit). Do while loop executes at least once when if the condition is … Read more