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 "&nbsp;&nbsp;Middle<br /> ";
        while (1) {
            echo "&nbsp;&nbsp;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浜戝叾瀹冪浉鍏虫枃绔狅紒



鏈枃URL锛http://www.odweb.cn/news_show.html?id=82