break
break 结束当前 for,foreach,while,do-while 或者 switch 结构的执行。
continue
结束当前循环,跳转到下次例:
while(1){
if( $mrs['lm_name']=='首页' || $mrs['lm_name']=='论坛'){continue;}
}
立即学习“PHP免费学习笔记(深入)”;
break 可以接受一个可选的数字参数来决定跳出几重循环。
$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
\n";
}
/* Using the optional argument. */
$i = 0;
while (++$i) {
switch ($i) {
case 5:
echo "At 5
\n";
break 1; /* Exit only the switch. */
case 10:
echo "At 10; quitting
\n";
break 2; /* Exit the switch and the while. */
default:
break;
}
}
?>
PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号