phpicoder Nov 2, 2021 php

Hi guys, In this tutorial, we will learn do-while loop statement to execute a code block repeatedly based on a condition checked at the end of each iteration using php.

This loop is used when position looping is performed after executing statements within the loop. This means that do-while would execute its statements at least once, even if the condition fails for the first time itself.

php do while It is also called an exit-controlled loop.

    code to be executed;
} while (condition);

Example: print 1 to 5 using do-while loop.


  $i = 1;
  	echo "The number is: $i <br>";
  }while($i <= 5);

The number is: 1
The number is: 2
The number is: 3
The number is: 4
The number is: 5
I hope this tutorial help for you.