This forum is now read-only. Please use our new forums at discuss.codecademy.com.

Control Flow: Switch Forum

View Course » View Exercise

209 points
4311423a8ab6a0f77339f821aadc628f?s=140&d=retro
Submitted by
Paul
over 4 years ago

Oops message appears when correct result appears

I got an "Oops, try again. Make sure you make at least one case block!" message even though the "Yummy" result appears. Did I do something wrong, or is this a problem with the exercise?


3 votes

permalink

<!DOCTYPE html>





<?php
$fruit = "Apple";

switch ($fruit) {
    case'Apple':
        echo "Yummy.";
        break;
}

?>
</body>

Bu it gives the error "Oops, try again! Make sure you add the default case!" Please help

286 points
F93704507ee78e9ea517c0825c0ac1b0?s=140&d=retro
Submitted by
sohil chawla
about 4 years ago

1 Comment

C162db03f8d4fad818a14ed1e3bcb199?s=140&d=retro annmueni over 3 years ago

"<!DOCTYPE html>





<?php
switch (1) {
case 1:
echo'$ 1 is equal to 0.';
case:1
case:2
case:3
case:4
break;
default:
echo" it is equal/$ 1 is.";
}


0 votes

permalink

Looks good just make sure you use semicolons. other than that it worked for me.

102 points
C539ccb3bf4bd92ccdba0a22b3f4f423?s=140&d=retro
Submitted by
VictoriaC.
over 4 years ago


0 votes

permalink

Ok so what needs to happen for this exercise is this:
break;
default:
echo " You can put anything you like here!";
}

568 points
527b25d4f10c60f6f0001296_126688457
Submitted by
j-press
about 4 years ago


-4 votes

permalink

You have to post your code for us to know where you went wrong.

Meanwhile make sure you followed the instructions, including adding the default case and check your punctuation.

1991 points
4f74a61860cd570003003e72_283945339
Submitted by
Julia Toos
over 4 years ago

3 Comments

4311423a8ab6a0f77339f821aadc628f?s=140&d=retro Paul over 4 years ago

Thanks. Here's what I posted:

<!DOCTYPE html>





<?php
$fruit = "Apple";

switch ($fruit) {
    case 'Apple':
        echo "Yummy.";
        break;
}

?>
</body>

It produced "Yummy" in the results page, but also showed "Oops, try again."

517f0fe4855b557469000ece_881046890 Joshua Osborne over 4 years ago

Please use the code sample button next time. After copy and pasting your code, highlight it, then press the "Code Sample" button.

Fab6d0a8584e96267e7b81f3b9f6c411?s=140&d=retro virus316 over 4 years ago

how