In the code below, I understand the $place variable and how it's working. What I
can't understand is how I'M getting the output "he played 1, 2, etc... How is
that function and the $stanza variable returning a single digit number? Thanks
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>
<html xmlns="http://www.w3.org/1999/xhtml";>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Param Old Man</title>
</head>

<body>

<h1>Param Old Man</h1>
<h3>Demonstrates use of function parameters</h3>
<?php

print verse(1);
print chorus();
print verse(2);
print chorus();
print verse(3);
print chorus();
print verse(4);
print chorus();

function verse($stanza)
{
        switch($stanza)
        {
                case 1:
                        $place = "thumb";
                        break;
                case 2:
                        $place = "shoe";
                        break;
                case 3:
                        $place = "knee";
                        break;
                case 4:
                        $place = "door";
                        break;
                default:
                        $place = "I don't know where";
        } //end switch

        $output = <<<HERE
        This old man, he played $stanza<br>
        He played knick-knack on my $place<br><br>
HERE;
        return $output;
} //end veruse

function chorus()
{
        $output = <<<HERE
        ...with a knick-knack<br>
        paddy-wack<br>
        give a dog a bone<br>
        this old man came rolling home<br>
        <br><br>
HERE;
        return $output;
}// end chorus

?>
</body>
</html>

-- 
Thanks & regards,
Lokananth

<http://forum.pspad.com/read.php?6,50282,50282>
PSPad freeware editor http://www.pspad.com

Odpovedet emailem