Re: Passing by reference...
| From: | Michael Sims | Date: | Tue, 01 Jan 2002 00:57:04 +0000 |
| Subject: | Re: Passing by reference... | ||
| References: | 1 | Groups: | php.windows |
| Request: | Send a blank email to php-windows+get-11243@lists.php.net to get a copy of this message | ||
At 07:37 PM 12/31/2001 -0600, Anthony Ritter wrote:
.................................. <? function tax (&$Salary) { $Salary= $Salary - (($Salary/100)*20); return $Salary; } $Salary=2500; echo $Salary; ?> ...................................... The result in the textbook is 2000 but I'm getting 2500.That particular snippet of code *should* echo 2500...because you're not even calling the function. You're setting the $Salary variable equal to 2500 and then immediately echoing it... Add this line before the last one: tax($Salary); And it should then echo 2000... If you typed it in correctly then the book must have a misprint...