The Syntax Struggle is Alive and Real


#1


https://www.codecademy.com/en/courses/web-beginner-en-jZv2E/0/6?curriculum_id=5124ef4c78d510dd89003eb8


Syntax error on line 8 is the error message. Could someone please show me what is messed up? Thanks


   <?php
     $name = "jake":
    
    switch ($name):
        
    case ($name = "harry"):
    case ($name = "jake"):
    case ($name = "meg"):
         print "mmmm yeh";
         break;
    
    case ($name = "jessica"):
         print "ohhh yes";
         break;
    
    case ($name = "madeline"):
        print "hey";
        break;
        
    default: print "love me love me"
         
    endswitch;
    ?>


#2

This -> $name = "jake": is a simple assign operation, you should end it with a semicolon, not a colon.


You have opened and ended your switch statement in the incorrect way. Take a look at the documentation to find the correct syntax -> http://php.net/manual/en/control-structures.switch.php.


#3

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