(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 | ȡ��������Ϊ�������ݣ����� $num = 2; break $num;���� |