07-27-2009, 08:13 PM
|
#2 (permalink)
|
|
The Acquainted
Join Date: Nov 2007
Posts: 166
Thanks: 0
|
Neither of those are passing a variable by reference.
In snippet 1, $p1 is being copied into $a1->accountOwner. Both variables have their own location within the memory. Put an & in front of the variable and both variables will be using the same location in memory making $a1->accountOwner and $p1 essentially the same whereas before they were two different objects in memory.
PHP Code:
$p1->name = 'John'; $a1->accountOwner = &$p1;
$a1->accountOwner->name = 'Bob'; echo $p1->name; // returns 'Bob'
__________________
Eric
|
|
|
|