exit loopbreak

Exit the loop break

The format is as follows:

for(初始条件;判断条件;循环后条件值更新) { if(特殊情况) {break;} 循环代码 }

When a special situation is encountered, the loop will end immediately. Take a look at the example below, which outputs 10 numbers. If the value is 5, it stops outputting.

   

The output results are as follows

QQ截图20161012134415.png

Note: When num=5, the loop will end and the content of the subsequent loop will not be output.

   

点击按钮,测试带有 break 语句的循环。


Continuing Learning
||
break
submit Reset Code
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!