Monday, January 26, 2009

How to display numbers using while loop in php?

while statement is one of loop statement in Php that
has a specific condition depending the program flows. The while loop
statement will automatically stop if the condition becomes false for
example if you creating a simple program displaying numbers
the
while loop statement will stop displaying numbers base in a given value
or the count of the loop on how many times the loop repeat.

while (condition)
code to be executed;

Simple looping using while loop
Example:

$i=1;
while($i<=10)
{
echo "The number is " . $i . "
";

$i++;
}

Output:

The number is 1
The number is 2
The number is 3
The number is 4
The number is 5

Download File

1 comment:

  1. is thie code can apply to the windows or pc?...

    ReplyDelete

 

blogger templates | Make Money Online