我尝试在switch中设置值。根据这段代码,应该回应“你最喜欢的颜色是红色”,但事实并非如此。当我运行此代码时,它会给出一个结果:
你最喜欢的颜色既不是红色,也不是蓝色,也不是绿色!但是红色。
这是我的代码
<?php
$response = null;
switch ($msg) {
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, nor green! but " . $msg . " colour.";
}