View Single Post
Old 07-27-2009, 08:13 PM   #2 (permalink)
wGEric
The Acquainted
 
wGEric's Avatar
 
Join Date: Nov 2007
Posts: 166
Thanks: 0
wGEric is on a distinguished road
Default

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
wGEric is offline  
Reply With Quote