do-while is similar to a while loop and used when a set of statements have to be
repeatedly executed at least once untile a certain condition is reached. When we do
not know exactly how many time a set of statement have to be repeated do while
can be used.
Q.) W.A.P to print 1 to 5 using while loop.
<html>
<body>
<?php
$i=1;
do
{
echo $i;
$i++;
}while($i<=5);
?>
</body>
</html>
Output
1
2
3
4
5