Unexplainable output


#1



Unit 3 exercise 3


Does anybody understand why this code it echo-ing "too bad"?? I dont understand because I set the variable fruit to Apple, and I tell it to echo "yummy"....


<!DOCTYPE html>
<html>
	<head>
		<title></title>
	</head>
	<body>
    <?php
    $fruit = "Apple";
    
    switch ($fruit) {
        case 1: "Apple";
            echo "Yummy"; 
            break;
            default: echo "too bad";
    }
    
    ?>
    </body>
</html>


#2

There is a wrong syntax.

The first case statement (case 1: "Apple";) will be executed if the $fruit is equal to 1, not to "Apple":

case "Apple":

#3

Thanks this was helpful!