PHP鎺у埗缁撴瀯涔媤hile

鍐呭鎽樿
while 寰幆鏄 PHP 涓渶绠鍗曠殑寰幆绫诲瀷銆傚畠鍜 C 璇█涓殑 while 琛ㄧ幇寰椾竴鏍枫
鏂囩珷姝f枃
while
while 寰幆鏄 PHP 涓渶绠鍗曠殑寰幆绫诲瀷銆傚畠鍜 C 璇█涓殑 while 琛ㄧ幇寰椾竴鏍枫倃hile 璇彞鐨勫熀鏈牸寮忔槸锛

while (expr)
    statement
while 璇彞鐨勫惈鎰忓緢绠鍗曪紝瀹冨憡璇 PHP 鍙 while 琛ㄨ揪寮忕殑鍊间负 TRUE 灏遍噸澶嶆墽琛屽祵濂椾腑鐨勫惊鐜鍙ャ傝〃杈惧紡鐨勫煎湪姣忔寮濮嬪惊鐜椂妫鏌ワ紝鎵浠ュ嵆浣胯繖涓煎湪寰幆璇彞涓敼鍙樹簡锛岃鍙ヤ篃涓嶄細鍋滄鎵ц锛岀洿鍒版湰娆″惊鐜粨鏉熴傛湁鏃跺欏鏋 while 琛ㄨ揪寮忕殑鍊间竴寮濮嬪氨鏄 FALSE锛屽垯寰幆璇彞涓娆¢兘涓嶄細鎵ц銆

鍜 if 璇彞涓鏍凤紝鍙互鍦 while 寰幆涓敤鑺辨嫭鍙锋嫭璧蜂竴涓鍙ョ粍锛屾垨鑰呯敤鏇夸唬璇硶锛

while (expr):
    statement
    ...
endwhile;
涓嬮潰涓や釜渚嬪瓙瀹屽叏涓鏍凤紝閮芥樉绀烘暟瀛 1 鍒 10锛 <?php
/* example 1 */

$i = 1;
while ($i <= 10) {
    echo $i++;  /* the printed value would be
                    $i before the increment
                    (post-increment) */
}

/* example 2 */

$i = 1;
while ($i <= 10):
    print $i;
    $i++;
endwhile;
?>

浠ヤ笂灏辨槸PHP鎺у埗缁撴瀯涔媤hile鐨勮缁嗗唴瀹癸紝鏇村淇℃伅璇峰叧娉∣D浜戝叾瀹冪浉鍏虫枃绔狅紒



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