OkFx.Net, get rebates from your trade

while Statement

While is some Looping statements in PHP

The while statement will execute a block of code if and as long as a condition is true.

while (condition)
{code to be executed;}

Example

The following example demonstrates a loop that will continue to run as long as the variable i is less than, or equal to 5. i will increase by 1 each time the loop runs:

<html>
<body>
<?php
$i=1;
while($i<=5)
{
echo “The number is ” . “$i” . “<br />”;
$i++;
}
?>
</body>
</html>

And output is

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


Related post :
  • The for Statement
  • The foreach Statement
  • PHP If…Else Statements
  • The do…while Statement
  • How to Use the PHP Include Statement
  • Leave a Reply