PHP: All on Your Own


#1

$age=21;
switch ($age){
case 1:
echo "21";
break;
case 2:
echo "23"
break;
case 3:
echo "22";
break;
}
?>
This worked but it said Parse error: syntax error, unexpected T_BREAK, expecting ',' or ';' on line 15.
I'm trying to figure out what the error was even though it was accepted.


#2

We cannot tell which is line 15, but you should be able to. Count from the top line if there are no line numbers showing.

This must be line 15 since it matches the error message perfectly.

Aside

To be able to write working code we need to have a good idea of what is expected from our code so we can design that into the program. What is expected from your code? As it is, nothing happens or is echoed, even with the parse error solved. What case will $age match up to? Answer... None. What gives with this?