ControllingYourCodewithConditionsandFunctions$die1 = rand(1,6); $die2 = rand(1,6); $die3 =
September 29, 2006 on 3:27 pm | In php |ControllingYourCodewithConditionsandFunctions$die1 = rand(1,6); $die2 = rand(1,6); $die3 = rand(1,6); $die4 = rand(1,6); $die5 = rand(1,6); showDie($die1); showDie($die2); showDie($die3); showDie($die4); showDie($die5); print
; calcNumPetals($die1); calcNumPetals($die2); calcNumPetals($die3); calcNumPetals($die4); calcNumPetals($die5); } // end printDiceThe printDice()function is very concerned with the $numPetalsvariable, butdoesn t need access to $guess. It requests access to $numPetalsfrom the main pro- gram. After printing out the New Roll message, it resets $numPetalsto 0. Thevalue of $numPetalsis recalculated each time the dice are rolled. I got new dice values by calling the rand(1, 6)function six times. I stored eachresult in a different variable, named $die1to $die6. To print out an appropriategraphic for each die, I called the showDie()function. I printed out a line break, then called the calcNumPetals()function once for each die. The showDie() FunctionThe showDie()function is used to simplify repetitive code. It accepts a die valueas a parameter and generates the appropriate HTML code for drawing a die withthe corresponding number of dots. function showDie($value){ print <<
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 = '172' AND comment_approved = '1' ORDER BY comment_date
No Comments yet
Sorry, the comment form is closed at this time.
Powered by cheap hosting