教程集 www.jiaochengji.com
教程集 >  脚本编程  >  php  >  正文 php流程控制 break continue

php流程控制 break continue

发布时间:2016-10-30   编辑:jiaochengji.com
教程集为您提供php流程控制 break continue等资源,欢迎您收藏本站,我们将为您提供最新的php流程控制 break continue资源

break
break 结束当前 for,foreach,while,do-while 或者 switch 结构的执行。

continue

结束当前循环,跳转到下次例:

while(1){

  if( $mrs['lm_name']=='首页' || $mrs['lm_name']=='论坛'){continue;}

}

break 可以接受一个可选的数字参数来决定跳出几重循环。


<?php
$arr = array('one', 'two', 'three', 'four', 'stop', 'five');
while (list (, $val) = each($arr)) {
if ($val == 'stop') {
break; /* You could also write 'break 1;' here. */
}
echo "$val<br />\n";
}

/* Using the optional argument. */

$i = 0;
while ( $i) {
switch ($i) {
case 5:
echo "At 5<br />\n";
break 1; /* Exit only the switch. */
case 10:
echo "At 10; quitting<br />\n";
break 2; /* Exit the switch and the while. */
default:
break;
}
}
?> 
 
 

您可能感兴趣的文章:
php流程控制 break continue
php中有哪几种流程控制结构
php流程控制命令:continue和break
php continue和break流程控制语名用法
php循环语句控制break与continue的用法举例
php中 continue break exit return 的区别
php5中哪几种流程结构
PHP笔记5:PHP流程控制分支结构
linux shell学习之shell流程控制
php入门教程-适合初学者教程

[关闭]
~ ~