note 76548 deleted from language.functions by levim
| From: | levim@php.net | Date: | Sun, 07 Jul 2013 18:40:46 +0000 |
| Subject: | note 76548 deleted from language.functions by levim | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-195485@lists.php.net to get a copy of this message | ||
Note Submitter: wassermann at REMOVEucdavis dot edu
----
deek at none dot net,
The explanation of why your example does what it does is not quite right.
function ChangeString(&$SuplyedString)
{
$SuplyedString = "BBB";
};
ChangeString($AAA='AAA');
print $AAA;
exit;
The assignment does, in fact, get executed before the function call. The reason that this prints
'AAA' is because '=' is an operator that returns the value that it assigned. In
this case, the value 'AAA' is assigned to the variable $AAA, and the assignment expression
returns a value of 'AAA'. It is this returned value that gets passed as an argument to
the function, and this returned value is unconnected to the variable $AAA.
$AAA = 'AAA';
ChangeString($AAA);
print $AAA;
exit;
In this case, a reference to the variable is being passed. Hope this helps...