View Single Post
Old 12-08-2007, 01:13 AM   #12 (permalink)
Haris
The Frequenter
Prolific Welcomer Upcoming Programmer 
 
Join Date: Sep 2007
Posts: 360
Thanks: 24
Haris is on a distinguished road
Default

Quote:
Originally Posted by Wildhoney View Post
In extension to Karl's, consider this:

php Code:
$a = 1;
$b =& $a;
$b = 2;

In the above example, both $a and $b now equal 2 because $b has been set as a reference to $a and so whatever $b becomes, $a becomes as well.

In a more complicated example:

php Code:
$aArray = array('Apple', 'Orange', 'Kiwi', 'Pear');
$pItem =& $aArray[2];
$pItem = 'Pitaya';

As $pItem is now a reference to the third item in our array, changing its value will also change the value in the array, so Kiwi now becomes Pitaya.
Thanks, got that.
Haris is offline  
Reply With Quote