PHP while 循环
The while
loop - Loops through a block of code as long as the specified condition is true.
PHP while 循环
The while
loop executes a block of code as long as the specified condition is true.
注意: 请记住递增 $i
,否则循环将永远持续下去。
The while
loop does not run a specific number of times, but checks after each iteration if the condition is still true.
The condition does not have to be a counter, it could be the status of an operation or any condition that evaluates to either true or false.
break 语句
With the break
statement we can stop the loop even if the condition is still true
continue 语句
使用 continue
语句,我们可以停止当前循环,并继续下一个循环。
替代语法
while
循环语法也可以用 endwhile
语句写成这样。
步骤 10
如果你想让 while
循环计数到 100,但每次只加 10,你可以在每次循环中将计数器增加 10 而不是 1。