Lesson 6: All on Your Own!


#1


Hello, I am getting some weird errors when i try to run this code.
the first error I got was 'Parse error: syntax error, unexpected '}' on line 18'. I got the same error but on line 19 then on line 21(all of the errors happen with both switches). What am I doing wrong?

    <?php
    $string = "orange";
        switch($string) {
            case "orange":
                echo "orange";
                break;
            case "banana":
                echo "banana";
                break;
            case "apple":
                echo "apple";
                break;
            default:
                echo "oops";
        }
    ?>

    <?php
    $string = "orange";
        switch($string):
            case "orange":
                echo "orange";
                break;
            case "banana":
                echo "banana";
                break;
            case "apple":
                echo "apple";
                break;
            default:
                echo "oops";
        endswitch;
    ?>

EDIT: I fixed it by refreshing the browser until it worked.


#2

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.