Re: Understanding the =& operator...

From: Date: Fri, 25 Oct 2002 21:52:21 +0000
Subject: Re: Understanding the =& operator...
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-121484@lists.php.net to get a copy of this message
"Chris Boget" <chris@wild.net> wrote in message news:023501c27c62$23b74dd0$8c01a8c0@ENTROPY... > Ok, let me see if I have this right: > > When you do: > > $var = new myClass(); > > $var instantiates and holds a copy of myClass. No. The "new" operator makes a new object which is an instance of class "myClass". > But when you do: > > $var =& new myClass(); > > $var instantiates and references that instantiation? No, this is no different than your first example. Maybe this is even a syntax error, I'm not positive about that though. > > If so, then I'm curious - if you do: > > $var2 =& new myClass(); > > and you modify the member variables in $var2, will the > member variables of $var be modified as well? Or does > $var2 reference a seperate instantiation? They are separate instances, because the "new" operator made a brand new object each time it was called. To make them reference the same object, you'd instantiate $var1 and then do $var2 =& $var1;

« previous php.general (#121484) next »