Re: By reference

From: Date: Thu, 13 Feb 2003 21:14:03 +0000
Subject: Re: By reference
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-135523@lists.php.net to get a copy of this message
On Thu, 13 Feb 2003, Chris Boget wrote: > $firstVar = "123ABC"; > > $secondVar &= $firstVar; &= is a bitwise AND, and an assignment. This didn't do what you expected it to do. > $thirdVar = &$firstVar; =& is a reference assignment. This did what you expected it to do. > Why? I thought that "&=" made it so that the left operand was > pointing to the memory location of the right? You make the left operand point to the memory location of the right operand with =&. =& is the only reference assignment available, besides passing/returning by reference with functions. $stuff = "1234"; $ref =& $stuff; // $ref points to $stuff's data print $ref . "\n"; // prints "1234" $stuff = "5678"; print $ref . "\n"; // prints "5678" hth, ~Chris

« previous php.general (#135523) next »