I try to case value inside switch. According to this code, it should be echo "Your favorite color is red", but it doesn't. When I run this code, it give a result:
Your favorite color is neither red, blue, nor green! but red colour.
Here is my code
<?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.";
}
$msg
) is exactly as it is in thecase
by usingtrim
and validate it withisset
andempty
.