Use a while
loop to print numbers from 1 to 5:
<?php
$i = 1;
while($i <= 5) {
echo $i;
echo "<br>";
$i++;
}
?>
Try it Yourself »
The while
keyword is used to create a while
loop and is also used to set the looping condition of a do...while
.
The do
keyword.
Read more about while loops in our PHP while Loop Tutorial.
Read more about do...while loops in our PHP do while Loop Tutorial.
截取页面反馈部分,让我们更快修复内容!也可以直接跳过填写反馈内容!