PHP Programs

Program using for loop

In this program demonstrate use of for loop. Loops are used to execute statement repeatedly depending on condition.

For loop is an Iterative Control Structure that executes code a number of times depending on condition.

Program

<html>

<head>

<title> For..loop</title>

</head>

<body>

<?php

$a=0;

$b=0;

 

for($i=0;$i<5;$i++)

{

  $a+=10;

  $b+=5;

}

    echo"at the end of the program a=$a

    and  b=$b";

?>

</body>

</html>

When Run The Program Following Output:

at the end of the program a=50 and b=25

Description

For loop is an Iterative Control Structure that executes code a number of times depending on condition.

Syntax of php for loop

 

for (initialize; condition; increment)

{

 Iterative code to be executed

}

Releted Programs

© 2017 codewmAll rights reserved.