Adsense 728 * 15

Search

Custom Search

For Loop in PHP




For loop


For loop is used when we know in advance how many times the loop is repeated.




Syntax of for loop-


for (initialisation; condition here ; increment/decrement)
  {
  //body of loop
  }


<?php


for($num=1;$num<=5;$num++)
{
echo "Hi Everyone"."<br/>"; 
}
?>


//Prints Hi everyone five times



<?php

for($num=1;$num<=5;$num++)
{
echo $num."<br/>"; 
}
?>

Output-

1
2
3
4
5





No comments:

Post a Comment