PHP do while

Last Updated: July 31, 2021

PHP do while loop

You can run a set of PHP code until a condition is true. This is the same as the while() loop except the loop runs at least one time.

Syntax

do{  
    //code to be executed  
}while(condition);  

PHP do while example to print numbers from 0 to 10

PHP do while example to calculate the sum of the numbers