PHP Switch 語句

PHP Switch 語句
switch (n)
 {
 case label1:
 若是 n=label1,此處代碼將執行;
 break;
 case label2:
 若是 n=label2,此處代碼將執行;
 break;
 default:
 若是 n 既不等於 label1 也不等於 label2,此處代碼將執行;
 } 
tch ( n )
代碼:
<?php
$favcolor="red";
switch ($favcolor)
{
case "red":
echo "Your favorite color is red!";
break;
case "blue":
echo "Your favorite color is blue!";
break;
case "green":
echo "Your favorite color is green!";
break;
default:
echo "Your favorite color is neither red, blue, or green!";
}
?>
相關文章
相關標籤/搜索