Unit-1 PHP
Unit-1 PHP
Ex.
$i = 1;
do {
if ($i == 3) break;
echo $i;
$i++;
} while ($i < 6);
PHP Loops and Branching Statements
3) for- loops- The for loop is used when you know how many times
the script should run.
Syntax:- for (expression1, expression2, expression3)
{
// code block
}
Ex.
for ($n = 1; $n <= 10; $n++)
{
echo "$n ";
} // Output: 1 2 3 4 5 6 7 8 9 10