The showDie() Function

chinmay.sahoo

New member
The showDie() function is used to simplify repetitive code. It accepts a die value as a parameter and generates the appropriate HTML code for drawing a die with the corresponding number of dots.


function showDie($value){
print <<<HERE
<img src = "die$value.jpg"
height = "100"
width = "100"
alt = "die: $value" />
HERE;
} // end showDie

One advantage of using functions for repetitive HTML code is the ease with which you can modify large sections of code. For example, if you wish to change image sizes, change the img tag in this one function. All six die images are changed at once!
 
Back
Top