Loops through a block of code as long as the condition specified equal to true.
Syntax
<?php while (when condition is true) { code to be executed; } //or while(condition): //code to be executed endwhile; ?>
Examples
The example below displays the numbers from 1 to 6:
<?php $x=1; while($x<=6){ echo "$x
"; $x++; } $x=1; while($x<=6): echo "$x
"; $x++; endwhile; ?>