Re: Passing by reference...
| From: | Anthony Ritter | Date: | Tue, 01 Jan 2002 02:51:59 +0000 |
| Subject: | Re: Passing by reference... | ||
| References: | 1 2 | Groups: | php.windows |
| Request: | Send a blank email to php-windows+get-11244@lists.php.net to get a copy of this message | ||
Michael,
The following is the code taken line for line from Wrox - Beginning PHP - on
page 204.
...............................................
<?
function tax (&$Salary)
{
$Salary= $Salary - (($Salary/100)*20);
return $Salary;
}
$Salary=2500;
echo (tax($Salary)); // This displays $2000
echo $Salary; // This also displays $2000
?>
........................................
The question really was about the *ampersand* in the argument line which
supposedly changes the value of the variable to 2000 from 2500 because of
the ampersand symbol.
function tax(&$Salary)
Thanking all in advance,
Tony Ritter
........................................................
Michael Sims <mhsims@midsouth.rr.com> wrote in message:
> 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...
.....................................................