This site is mobile accessible. Press the "Tap Here" button to use a different font-size.


Smartphone icons created by Freepik - Flaticon

PHP Loops

The PHP while Loop

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

<?php  
// Initialize the loop counter ($x), and set the start value to 1
$x = 1;
 
// Continue the loop as long as $x is less than or equal to 5
while($x <= 5) {
  echo "The number is: $x <br>";
  $x++;
} 
?>

Example Explained