what is the difference between while and do while
Difference in While Loop and do While loop. In while loop the condition is checked at the starting of the loop and if it is true then the code inside the loop is executed. This process is repeated till the condition becomes false. In case of do while loop the checking of condition is done at the end of the loop. So even if the condition is false, the script inside the loop is executed at least once. This is the basic difference between do while loop and while loop. Let us start with one simple script with a do while loop to understand the syntax. Here the condition is checked at the end of the loop so the code inside the loop is executed for once. $i=1; do{.