ControllingYourCodewithConditionsandFunctions$die1 = rand(1,6); $die2 = rand(1,6); $die3 =

September 29, 2006 on 3:27 pm | In php |

width = 100> HERE; } // end showDieOne advantage of using functions for repetitive HTML code is the ease with whichyou can modify large sections of code. For example, if you wish to change imagesizes, change the imgtag in this one function. All six die images are changed. The calcNumPetals FunctionThe printDice()function also calls calcNumPetals()once for each die. This func- tion receives a die value as a parameter. It also references the $numPetalsglobalvariable. The function uses a switchstatement to determine how much to add to$numPetalsbased on the current die s value. Here s the trick: The center dot of the die is the rose. Any dots around the centerdot are the petals. The value 1has a rose but no petals; 2, 4, and 6have petals, butno rose; 3has two petals; 5has four. If the die roll is 3, $numPetalsshould beincreased by 2; if the roll is 5, $numPetalsshould be increased by 4. function calcNumPetals($value){ global $numPetals; switch ($value) { case 3: $numPetals +=2; break; case 5: $numPetals +=4; break; } // end switch} // end calcNumPetalsThe +=code is a shorthand notation. The line shown here$numPetals +=2; is exactly equivalent to this line: $numPetals = $numPetals + 2; TRICK92PHP5/MySQLProgrammingfortheAbsoluteBeginner
Note: If you are looking for cheap and inexpensive provider to host and run your tomcat application check Actions tomcat 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 = '173' AND comment_approved = '1' ORDER BY comment_date

No Comments yet

TrackBack URI

Sorry, the comment form is closed at this time.

Powered by cheap hosting