Press "Enter" to skip to content

phpfor

PHP for loop

PHP for loop run the code specified number of times.

SYNTAX


for(initialization; condition; increment)
{
// Code to be executed
}

PARAMETER

 

NameDescriptionRequired /Optional
ParameterInitialize the loop counter value 
ConditionIf it condition evaluates to TRUE, the loop continues. If it condition evaluates to FALSE, the loop ends.Required
incrementIncrement or Decrements the variable

Example for PHP for loop

<?php
//Display 1 to 10 Number

for($n=1;$n<=10;$n++)
{
echo “Number = $n<br>”;
}
?>