Re: Getting new object by ref.

From: Date: Thu, 21 Dec 2000 22:35:47 +0000
Subject: Re: Getting new object by ref.
References: 1 2 3  Groups: php.dev 
Request: Send a blank email to php-dev+get-42086@lists.php.net to get a copy of this message
At 00:29 22/12/2000, Andrei Zmievski wrote:
On Fri, 22 Dec 2000, Zeev Suraski wrote: It does work, only not with the semantics you expected, but with PHP's assign-reference semantics. $a = &$b; // $a and $b are references to the same value
$a = &$c;       // $a is broken away from $b, and now, $a and $c are
references to the same
                 // variable - $b is standalone
The same thing happens here. As you know, 'global $foo' creates a local variable, $foo, which is a reference to the $foo variable in the global scope. If you assign-reference to the local $foo, the reference to the global $foo will be broken. So, what's the way around it, use $GLOBALS["foo"]?
Yes. That's the consistent way of doing things with the current object model. Zeev Zeev Suraski <zeev@zend.com> CTO & co-founder, Zend Technologies Ltd. http://www.zend.com/

« previous php.dev (#42086) next »