Re: Getting new object by ref.
| From: | Andrei Zmievski | Date: | Thu, 21 Dec 2000 22:29:12 +0000 |
| Subject: | Re: Getting new object by ref. | ||
| References: | 1 2 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-42085@lists.php.net to get a copy of this message | ||
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"]? That sucks...
-Andrei
"In My Egotistical Opinion, most people's C programs should be indented
six feet downward and covered with dirt." -- Blair P. Houghton