如果 $color
既不是“红色”也不是“绿色”,则添加一个将输出“Neither”的部分。
switch ($color) {
case "red":
echo "Hello";
break;
case "green":
echo "Welcome";
break;
@(8)
echo "Neither";
}
switch ($color) {
case "red":
echo "Hello";
break;
case "green":
echo "Welcome";
break;
default:
echo "Neither";
}