Lesson 3: Switch bug?


#1


It took me a moment, but I believe there's an issue with this one, unless it's intended to use ' instead of " to stump people into looking into the code. I kept getting a fail marker saying that I didn't write any cases when my code was finished.

This is the code that is supplied:

<!DOCTYPE html>
<html>
	<head>
		<title></title>
	</head>
	<body>
    <?php
    $fruit = "Apple";
    
    switch ($fruit) {
        __ 'Apple':
            echo "Yummy.";
            __;
    }
    
    ?>
    </body>
</html>

Here's the code that I submitted the first time:

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

I was given the error that I did not write the default case. As soon as I changed 'Apple' to "Apple" it submitted fine.

I guess my question is, is this intended? After looking around, it seems a few people have had weird bugs with this specific lesson.


#2

I'm not sure what was the problem. I noticed that PHP courses had fair share of unusual problems, but for me the code worked with both ' and " in this exercise. You should have probably just refreshed the page and it would have worked.


#3

Having to refresh the page every single lesson with no extensions on my chrome besides a password manager is quite ridiculous though....


#4

Yes, I completely agree. That's why I loved most courses here, but hated PHP. I switched to IE for last couple of exercises and had no problems there, but it's funny how in Chrome you need to refresh at least per exercise to make it work. Well, nothing is bug free. :slight_smile:


#5

Oh I loved the Ruby course, but I did that almost a year back and probably on Firefox, might have to download Firefox again just to finish the PHP course.


#6

Yeah the PHP course is riddled with bugs.


#7

But it's still a good course, right? :slight_smile:
I think it provides good info about basic concept and most used methods and introduces you to working with arrays, which is great thing. There is ofcourse much more to PHP than that, but it does gives good insight about language's basic concepts.