Returning to the Petals GameAt the beginning of
September 29, 2006 on 11:20 am | In php |} else if ($guess == $numPetals){ print
You Got It!
; } else { print <<
from last try:
you guessed: $guess
-and the correct answer was: $numPetals petals around the rose
HERE; } // end if} // end printGreetingThis function refers to both the $guessand $numPetalsvariables, which are auto- matically created. You can use one globalstatement to make more than one vari- able global by separating the variables with commas. The $guessvariable is empty if this is the first time the user has come to the pro- gram. If $guessis empty, I print a welcoming greeting. The user has guessed cor- rectly if $guessis equal to $numPetals, so I print an appropriate congratulations. Ifneither of these conditions is true (which is most of the time), the function printsout a slightly more complex string indicating the user s last guess and the correctanswer. This should give the user enough information to finally solve the riddle. The else ifstructure turns out to be the easiest option for handling the threepossible conditions I want to check. The printDice() FunctionAfter the program prints a greeting, it does the important business of generatingthe random dice. It s relatively easy to generate random dice, as you saw earlierin this chapter. However, I also wanted to be efficient and calculate the correctnumber of petals. To make the printDice()function more efficient, it calls someother custom functions. function printDice(){ global $numPetals; print
New Roll:
; $numPetals = 0; 90PHP5/MySQLProgrammingfortheAbsoluteBeginner
Note: If you are looking for reliable and quality webspace company to host and run your servlet application check Actions servlet hosting services
WordPress database error: [Table './sandzak_com_-_blog/wp_comments' is marked as crashed and should be repaired]
SELECT * FROM wp_comments WHERE comment_post_ID = '171' AND comment_approved = '1' ORDER BY comment_date
No Comments yet
Sorry, the comment form is closed at this time.
Powered by cheap hosting