PHP While
PHP While
While syntax
while (expression is true) {
execute statement
}
While example
<html> <body> <?php $x = 1; while ($x <= 3) { echo "<br />"; echo "x = ", $x++; } ?> </body> </html>
Result
x = 1
x = 2
x = 3
while (expression is true) {
execute statement
}
<html> <body> <?php $x = 1; while ($x <= 3) { echo "<br />"; echo "x = ", $x++; } ?> </body> </html>
x = 1
x = 2
x = 3