PHP - Do While Loop

The do..while statement will always execute the block of code once,it will then check the condition,and repeat the loop while the condition is true,that means do while is exit control loop the following diagram represent exit control loop.

PHP - Do While Loop

Syntax


<?php
	do
	{
		code to be executed
		increment & decrement
	}while(condition);
?>								
							

Example



<?php

	$a=1;
	do
	{
		$a++;
		echo $a."
"; $a++; }while($a<=5); ?>

Output


1
2
3
4
5
							
Share Share on Facebook Share on Twitter Share on LinkedIn Pin on Pinterest Share on Stumbleupon Share on Tumblr Share on Reddit Share on Diggit

You may also like this!