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

Control Flow: Switch Forum

View Course » View Exercise

471 points
Dac0d9ddade5a3d470a2b7d590d34b50?s=140&d=retro
Submitted by
ninaruth
about 3 years ago

My code passes but shows an error?

This code passes, but returns the error:

Parse error: syntax error, unexpected T_IF on line 9

Any clue what's wrong? Code is below.

<!DOCTYPE html>
<html>
<head>
    <title></title>
</head>
<body>
<?php
    $cow = 5
    if (cow < 5) { //this is the line that shows an error//
        echo "Small!";
    }
    elseif (cow = 5) {
        echo "Medium!";
    }
    else {
        echo "Large!";
    }
?>
</body>

2 votes

permalink

you've a missing semicolon where u assigned a value of 5 to your variable..and u also forgot a $ sign before your variable names in two places.

105 points
545d7e688c1ccc3380000f0d_961485257
Submitted by
shellCoder
about 3 years ago

3 Comments

Dac0d9ddade5a3d470a2b7d590d34b50?s=140&d=retro ninaruth about 3 years ago

Thanks! I'm finding the PHP track is so buggy it's hard to know when I've actually done something incorrectly.

545d7e688c1ccc3380000f0d_961485257 shellCoder about 3 years ago

It's nothing dude,and it's not hard to find what u've done wrong in your code..you just need enough practice and faith in yourself.thanx

545d7e688c1ccc3380000f0d_961485257 shellCoder about 3 years ago

always remember this :in php every statement must end with a semicolon,variable name starts with a $ sign, The first character of a variable name can't be a number, simple as that.