News:

Choose a design and let our professionals help you build a successful website   - ITAcumens

Main Menu

The while Statement in PHP

Started by sajiv, Aug 18, 2008, 04:05 PM

Previous topic - Next topic

sajiv


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

Syntax
Code:
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:

Code:
<html>
<body>

<?php
$i=1;
while($i<=5)
  {
  echo "The number is " . $i . "
";
  $i++;
  }
?>

</body>
</html>


:acumen