(PHP 4, PHP 5, PHP 7)
break 锟斤拷锟斤拷锟斤拷前 for锟斤拷foreach锟斤拷while锟斤拷do-while 锟斤拷锟斤拷 switch 锟结构锟斤拷执锟叫★拷
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";
}
/* 使锟矫匡拷选锟斤拷锟斤拷 */
$i = 0;
while (++$i) {
switch ($i) {
case 5:
echo "At 5<br />\n";
break 1; /* 只锟剿筹拷 switch. */
case 10:
echo "At 10; quitting<br />\n";
break 2; /* 锟剿筹拷 switch 锟斤拷 while 循锟斤拷 */
default:
break;
}
}
?>
锟芥本 | 说锟斤拷 |
---|---|
5.4.0 | break 0; 锟斤拷锟劫合凤拷锟斤拷锟斤拷锟斤拷之前锟侥版本锟斤拷锟斤拷锟斤拷为 break 1;锟斤拷 |
5.4.0 | 取锟斤拷锟斤拷锟斤拷锟斤拷为锟斤拷锟斤拷锟斤拷锟捷o拷锟斤拷锟斤拷 $num = 2; break $num;锟斤拷锟斤拷 |