PHP鎺у埗缁撴瀯涔嬫浛浠h娉
鍐呭鎽樿
PHP 鎻愪緵浜嗕竴浜涙祦绋嬫帶鍒剁殑鏇夸唬璇硶锛屽寘鎷 if锛寃hile锛宖or锛宖oreach 鍜 switch銆傛浛浠h娉曠殑鍩烘湰褰㈠紡鏄妸宸﹁姳鎷彿锛坽锛夋崲鎴愬啋鍙凤紙:锛夛紝鎶婂彸鑺辨嫭鍙凤紙}锛夊垎鍒崲鎴 endif;锛宔ndwhile;锛宔ndfor;锛宔ndforeach; 浠ュ強 endswitch;銆
鏂囩珷姝f枃
娴佺▼鎺у埗鐨勬浛浠h娉
PHP 鎻愪緵浜嗕竴浜涙祦绋嬫帶鍒剁殑鏇夸唬璇硶锛屽寘鎷 if锛寃hile锛宖or锛宖oreach 鍜 switch銆傛浛浠h娉曠殑鍩烘湰褰㈠紡鏄妸宸﹁姳鎷彿锛坽锛夋崲鎴愬啋鍙凤紙:锛夛紝鎶婂彸鑺辨嫭鍙凤紙}锛夊垎鍒崲鎴 endif;锛宔ndwhile;锛宔ndfor;锛宔ndforeach; 浠ュ強 endswitch;銆 <?php if ($a == 5): ?>
A is equal to 5
<?php endif; ?>
鍦ㄤ笂闈㈢殑渚嬪瓙涓紝HTML 鍐呭鈥淎 is equal to 5鈥濈敤鏇夸唬璇硶宓屽鍦 if 璇彞涓傝 HTML 鐨勫唴瀹逛粎鍦 $a 绛変簬 5 鏃舵樉绀恒
鏇夸唬璇硶鍚屾牱鍙互鐢ㄥ湪 else 鍜 elseif 涓備笅闈㈡槸涓涓寘鎷 elseif 鍜 else 鐨 if 缁撴瀯鐢ㄦ浛浠h娉曟牸寮忓啓鐨勪緥瀛愶細 <?php
if ($a == 5):
echo "a equals 5";
echo "...";
elseif ($a == 6):
echo "a equals 6";
echo "!!!";
else:
echo "a is neither 5 nor 6";
endif;
?>
鏇村渚嬪瓙鍙傝 while锛宖or 鍜 if銆
PHP 鎻愪緵浜嗕竴浜涙祦绋嬫帶鍒剁殑鏇夸唬璇硶锛屽寘鎷 if锛寃hile锛宖or锛宖oreach 鍜 switch銆傛浛浠h娉曠殑鍩烘湰褰㈠紡鏄妸宸﹁姳鎷彿锛坽锛夋崲鎴愬啋鍙凤紙:锛夛紝鎶婂彸鑺辨嫭鍙凤紙}锛夊垎鍒崲鎴 endif;锛宔ndwhile;锛宔ndfor;锛宔ndforeach; 浠ュ強 endswitch;銆 <?php if ($a == 5): ?>
A is equal to 5
<?php endif; ?>
鍦ㄤ笂闈㈢殑渚嬪瓙涓紝HTML 鍐呭鈥淎 is equal to 5鈥濈敤鏇夸唬璇硶宓屽鍦 if 璇彞涓傝 HTML 鐨勫唴瀹逛粎鍦 $a 绛変簬 5 鏃舵樉绀恒
鏇夸唬璇硶鍚屾牱鍙互鐢ㄥ湪 else 鍜 elseif 涓備笅闈㈡槸涓涓寘鎷 elseif 鍜 else 鐨 if 缁撴瀯鐢ㄦ浛浠h娉曟牸寮忓啓鐨勪緥瀛愶細 <?php
if ($a == 5):
echo "a equals 5";
echo "...";
elseif ($a == 6):
echo "a equals 6";
echo "!!!";
else:
echo "a is neither 5 nor 6";
endif;
?>
鏇村渚嬪瓙鍙傝 while锛宖or 鍜 if銆
浠ヤ笂灏辨槸PHP鎺у埗缁撴瀯涔嬫浛浠h娉曠殑璇︾粏鍐呭锛屾洿澶氫俊鎭鍏虫敞OD浜戝叾瀹冪浉鍏虫枃绔狅紒