decypher Posted July 19, 2007 Share Posted July 19, 2007 <?php print verse(1); print chorus(); print verse(2); print chorus(); print verse(3); print chorus(); print verse(4); print chorus(); function verse($stanza){ switch ($stanza){ case1: $place = "thumb"; break; case2: $place = "shoe"; break; case3: $place = "knee"; break; case4: $place = "door"; break; defeault: $place = "I don't know where"; break; } // end switch $output = <<<HERE This old man, he played $stanza<br> he played knick-knack on my $place<br><br> HERE; return $output; } // end verse Error: Parse error: syntax error, unexpected T_STRING, expecting T_CASE or T_DEFAULT or '}' in C:\Program Files\Abyss Web Server\htdocs\paramoldman.php on line 22 any ideas? Quote Link to comment Share on other sites More sharing options...
ToonMariner Posted July 19, 2007 Share Posted July 19, 2007 <?php function verse($stanza){ switch ($stanza) { case1: $place = "thumb"; break; case2: $place = "shoe"; break; case3: $place = "knee"; break; case4: $place = "door"; break; defeault: $place = "I don't know where"; } } // end switch ?> Quote Link to comment Share on other sites More sharing options...
chigley Posted July 19, 2007 Share Posted July 19, 2007 Was the error not in the typo of default? Quote Link to comment Share on other sites More sharing options...
decypher Posted July 19, 2007 Author Share Posted July 19, 2007 yeh it was default: and the 'cases' had to have a space between the numbers :] Quote Link to comment Share on other sites More sharing options...
ToonMariner Posted July 19, 2007 Share Posted July 19, 2007 the error was an omission of the closing brace for the switch statement. (I have only just noticed the typos) it shoudl all look like this <?php function verse($stanza){ switch ($stanza) { case 1: $place = "thumb"; break; case 2: $place = "shoe"; break; case 3: $place = "knee"; break; case 4: $place = "door"; break; default: $place = "I don't know where"; } } // end switch ?> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.