![]() |
PHP Help - Printable Version +- 2DWorlds Forums (http://2dworlds.buildism.net/forum) +-- Forum: Off Topic (http://2dworlds.buildism.net/forum/forumdisplay.php?fid=5) +--- Forum: Programming (http://2dworlds.buildism.net/forum/forumdisplay.php?fid=30) +--- Thread: PHP Help (/showthread.php?tid=5750) |
PHP Help - Chaos - 06-13-2011 I am getting an unexpected '}' error on line 21, but on line 21, I NEED that '}' to end the function! What should I do? <?php ini_set ('diplay_errors', 1); //set the system to display errors. (SOOO USEFUL) $num = rand(1,8); //assign the variable //start the function, while using elseif to save space. if ($num == 1) { print "<p>You got number 1, DOES THAT MEAN YOU ARE?</p>"; } elseif ($num == 2) { print "<p>Number 2, you got second my young student</p>"; } elseif ($num == 3) { print "<p>Magic number, 3 is. -Master Yoda</p>"; } elseif ($num == 4) { print "<p>4, or for. You decide.</p>"; } elseif ($num == 5) { print "<p>You has 5 fingers. OR DO YOU?</p>"; } elseif ($num == 6) { print "<p>6? 666? Oh dear lord what have I done? O_O</p>"; } elseif ($num == 7) { print "<p>7! You lucky boy! Or girl, how the hell should I know?</p>"; } else ($num == 8) { print "<p>You got 8! You win the prize! Call 1-800-YOU-FAIL for your FREE prize!</p>"; } ?> RE: PHP Help - noob007 - 06-13-2011 Make the "else" into "elseif". Lol and those aren't called functions... RE: PHP Help - Chaos - 06-13-2011 elseif and if are functions... Also, thank you. RE: PHP Help - noob007 - 06-13-2011 A function in PHP is this: Code: function eatCheese($whatKind) { xD RE: PHP Help - Chaos - 06-13-2011 Well then I will get technical, STATEMENT. I guess I just learned to know them as functions. Whatever. RE: PHP Help - noob007 - 06-13-2011 If you wanna get technical, the proper way of saying it would be, "I need the '}' to signify the end of the code fragment that's executed conditionally." :p RE: PHP Help - Chaos - 06-13-2011 Do you live to make me confused? RE: PHP Help - noob007 - 06-13-2011 Lolno. It's not that complicated once you read it over and over and analyze every few words. xD RE: PHP Help - Blandflakes - 06-13-2011 I think a switch would work better for that. RE: PHP Help - Dignity - 06-15-2011 Yes, a switch. |