anantamu.com


PHP While


WHILE : executes the nested statements repeatedly, as long as the while expression evaluates to true.

FOR: It is used for executing a block of statements repeatedly until a given condition returns false.

do-while : It loops are very similar to while loops, except the truth expression is checked at the end of each iteration instead of in the beginning.

break : It ends execution of the current for, foreach, while, do-while or switch structure.

continues : It skips the current iteration of the loop and continues with the next iteration.

WHILE Loop

<?php 
$x=0;
WHILE($x<=10)
{ 
echo " $x"; 
$x++;  
}
?>

FOR Loop

<?php 
FOR($x =0; $x<=10; $x++)
{
echo " $x";
}
?>

DO WHILE Loop

<?php 
$x=0;
DO
{ 
echo " $x"; 
$x++;
}
WHILE($x<=10);
?>

BREAKE Statement

<?php  
FOR($x =0; $x<=10; $x++)
IF($x==4){   BREAKE; }
echo " $x";

?>

CONTINUE Statement

<?php  
FOR($x =0; $x≶=10; $x++)
IF($x==4){   CONTINUE; }
echo " $x";
 ?>