This forum is now read-only. Please use our new forums! Go to forums
Oops, try again. Make sure you have three case blocks!
I have written a switch case program against statment:
“ Create a switch statement with 3 different cases and a default case if you wish. Feel free to use the alternative syntax as well!“
but it gives errror: Oopps, try again. Make sure you have three case blocks. I’m clearly making three cases
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<?php
$our_var = 33;
switch($our_var)
{
case $our_var < 1:
echo "Maybe i know but not in a mood to know";
break;
case $our_var == 33:
echo $our_var;
break;
case $our_var > 201;
echo "Just a random case wich wont work";
break;
default:
echo "This wont work either";
break;
}
?>
</body>
</html>
Answer 55f656d551b8876d160000c8
This community is so in active. What do you do if anyone gets stuck anywhere doing code academy i figured it out myself. The cases worked if we juts put the string in the case e.g
$our_var = "something";
switch ($our_var)
case "anything"
echo "This isn't right";
break;
case "something"
echo "right one";
break;
default:
echo "anything for everything";
break;
Answer 5612d5c73e0ec893610002b2
0 votes
your issue is that you have a semicolon after the third case rather than a colon. fix it and watch in amazement as your code works
Popular free courses
- Free Course
Learn SQL
In this SQL course, you'll learn how to manage large datasets and analyze real data using the standard data management language.Beginner friendly,4 LessonsLanguage Fluency - Free Course
Learn JavaScript
Learn how to use JavaScript — a powerful and flexible programming language for adding website interactivity.Beginner friendly,11 LessonsLanguage Fluency - Free Course
Learn HTML
Start at the beginning by learning HTML basics — an important foundation for building and editing web pages.Beginner friendly,6 LessonsLanguage Fluency
1 comments
what’s that?