note 76185 deleted from language.functions by levim
| From: | levim@php.net | Date: | Sun, 07 Jul 2013 18:40:34 +0000 |
| Subject: | note 76185 deleted from language.functions by levim | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-195484@lists.php.net to get a copy of this message | ||
Note Submitter: deek at none dot net
----
Small Note:
While passing variables by reference ...
This first example does <NOT> work as expected....
function ChangeString(&$SuplyedString)
{
$SuplyedString = "BBB";
};
ChangeString($AAA='AAA');
print $AAA;
exit;
This will print 'AAA' ... and not the referenced value of 'BBB' as expected. It
seems that the = sign is interpreted after the function is executed and not before as one might
think?
Thus the fix is simple but more typing...
Same function but use ...
$AAA = 'AAA';
ChangeString($AAA);
print $AAA;
exit;
This will now print 'BBB' as it should.
Hope it saves you some debug time...