The while
loop - Loops through a block of code as long as the specified condition is true.
The while
loop executes a block of code as long as the specified condition is true.
while (
condition is true) {
code to be executed;
}
The example below displays the numbers from 1 to 5:
This example counts to 100 by tens:
<?php
$x = 0;
while($x <= 100) {
echo "The number is: $x <br>";
$x+=10;
}
?>
Try it Yourself »
截取页面反馈部分,让我们更快修复内容!也可以直接跳过填写反馈内容!