PHP鎺у埗缁撴瀯涔媍ontinue
鍐呭鎽樿
continue 鍦ㄥ惊鐜粨鏋勭敤鐢ㄦ潵璺宠繃鏈寰幆涓墿浣欑殑浠g爜骞跺湪鏉′欢姹傚间负鐪熸椂寮濮嬫墽琛屼笅涓娆″惊鐜
鏂囩珷姝f枃
continue
continue 鍦ㄥ惊鐜粨鏋勭敤鐢ㄦ潵璺宠繃鏈寰幆涓墿浣欑殑浠g爜骞跺湪鏉′欢姹傚间负鐪熸椂寮濮嬫墽琛屼笅涓娆″惊鐜
Note: 娉ㄦ剰鍦 PHP 涓 switch 璇彞琚涓烘槸鍙互浣跨敤 continue 鐨勪竴绉嶅惊鐜粨鏋勩
continue 鎺ュ彈涓涓彲閫夌殑鏁板瓧鍙傛暟鏉ュ喅瀹氳烦杩囧嚑閲嶅惊鐜埌寰幆缁撳熬銆
<?php
while (list ($key, $value) = each($arr)) {
if (!($key % 2)) { // skip odd members
continue;
}
do_something_odd($value);
}
$i = 0;
while ($i++ < 5) {
echo "Outer<br /> ";
while (1) {
echo " Middle<br /> ";
while (1) {
echo " Inner<br /> ";
continue 3;
}
echo "This never gets output.<br /> ";
}
echo "Neither does this.<br /> ";
}
?>
鐪佺暐 continue 鍚庨潰鐨勫垎鍙蜂細瀵艰嚧娣锋穯銆備互涓嬩緥瀛愮ず鎰忎簡涓嶅簲璇ヨ繖鏍峰仛銆
<?php
for ($i = 0; $i < 5; ++$i) {
if ($i == 2)
continue
print "$i ";
}
?>
甯屾湜寰楀埌鐨勭粨鏋滄槸锛
0
1
3
4
鍙疄闄呯殑杈撳嚭鏄細
2
鍥犱负 print() 璋冪敤鐨勮繑鍥炲兼槸 int(1)锛岀湅涓婂幓浣滀负浜嗕笂杩板彲閫夌殑鏁板瓧鍙傛暟銆
continue 鍦ㄥ惊鐜粨鏋勭敤鐢ㄦ潵璺宠繃鏈寰幆涓墿浣欑殑浠g爜骞跺湪鏉′欢姹傚间负鐪熸椂寮濮嬫墽琛屼笅涓娆″惊鐜
Note: 娉ㄦ剰鍦 PHP 涓 switch 璇彞琚涓烘槸鍙互浣跨敤 continue 鐨勪竴绉嶅惊鐜粨鏋勩
continue 鎺ュ彈涓涓彲閫夌殑鏁板瓧鍙傛暟鏉ュ喅瀹氳烦杩囧嚑閲嶅惊鐜埌寰幆缁撳熬銆
<?php
while (list ($key, $value) = each($arr)) {
if (!($key % 2)) { // skip odd members
continue;
}
do_something_odd($value);
}
$i = 0;
while ($i++ < 5) {
echo "Outer<br /> ";
while (1) {
echo " Middle<br /> ";
while (1) {
echo " Inner<br /> ";
continue 3;
}
echo "This never gets output.<br /> ";
}
echo "Neither does this.<br /> ";
}
?>
鐪佺暐 continue 鍚庨潰鐨勫垎鍙蜂細瀵艰嚧娣锋穯銆備互涓嬩緥瀛愮ず鎰忎簡涓嶅簲璇ヨ繖鏍峰仛銆
<?php
for ($i = 0; $i < 5; ++$i) {
if ($i == 2)
continue
print "$i ";
}
?>
甯屾湜寰楀埌鐨勭粨鏋滄槸锛
0
1
3
4
鍙疄闄呯殑杈撳嚭鏄細
2
鍥犱负 print() 璋冪敤鐨勮繑鍥炲兼槸 int(1)锛岀湅涓婂幓浣滀负浜嗕笂杩板彲閫夌殑鏁板瓧鍙傛暟銆
浠ヤ笂灏辨槸PHP鎺у埗缁撴瀯涔媍ontinue鐨勮缁嗗唴瀹癸紝鏇村淇℃伅璇峰叧娉∣D浜戝叾瀹冪浉鍏虫枃绔狅紒