PHP鎺у埗缁撴瀯涔媌reak
break 缁撴潫褰撳墠 for锛宖oreach锛寃hile锛宒o-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 /> ";
}
/* 浣跨敤鍙夊弬鏁 */
$i = 0;
while (++$i) {
switch ($i) {
case 5:
echo "At 5<br /> ";
break 1; /* 鍙鍑 switch. */
case 10:
echo "At 10; quitting<br /> ";
break 2; /* 閫鍑 switch 鍜 while 寰幆 */
default:
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 /> ";
}
/* 浣跨敤鍙夊弬鏁 */
$i = 0;
while (++$i) {
switch ($i) {
case 5:
echo "At 5<br /> ";
break 1; /* 鍙鍑 switch. */
case 10:
echo "At 10; quitting<br /> ";
break 2; /* 閫鍑 switch 鍜 while 寰幆 */
default:
break;
}
}
?>
浠ヤ笂灏辨槸PHP鎺у埗缁撴瀯涔媌reak鐨勮缁嗗唴瀹癸紝鏇村淇℃伅璇峰叧娉∣D浜戝叾瀹冪浉鍏虫枃绔狅紒