PHP: All on Your Own


switch ($age){
case 1:
echo "21";
case 2:
echo "23"
case 3:
echo "22";
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.


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.


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?