The while loop - Loops through a block of code as long as the specified condition is true.
The PHP while Loop
The while loop executes a block of code as long as the specified condition is true.
ExampleGet your own PHP Server
Print $i as long as $i is less than 6:
Note: remember to increment $i, or else the loop will continue forever
Syntax
<?php
$i
= 1;
while ($i < 6) {
echo
$i;
$i++;
}
? >
<!DOCTYPE html> <html> <body> <?php # if statement in php $i =1; while(i<5){ echo $i; $i++; } ?> </body> </html>