RE: [PHP4BETA] Re: [PHP3] Re: [PHP4BETA] Re: [PHP3] OO
| From: | Shannon Weyrick | Date: | Tue, 10 Aug 1999 15:53:37 +0000 |
| Subject: | RE: [PHP4BETA] Re: [PHP3] Re: [PHP4BETA] Re: [PHP3] OO | ||
| References: | 1 | Groups: | php.version4 |
| Request: | Send a blank email to php-version4+get-3292@lists.php.net to get a copy of this message | ||
On Tue, 10 Aug 1999, you wrote:
> At 15:54 10/08/99 , Samuel Liddicott wrote:
>
>
>
> You have to know the internals of Zend and PHP to understand that, but I'll
> give you a sketch.
>
> $a = new object;
> $b = $a; // $a and $b now point to the same place in memory, but if
> one of them is changed,
> // they're separated and no longer point to the same
> memory, so that changes made to
> // $a won't be applied to $b and vice versa
Zeev,
Thanks for the insight, and I have a question to this statement related above.
I was running into a problem where, in a class method, I was creating a new
object, and trying to return this newly created object to the caller. The
caller was, however, recieving a copy of the object, and changes made to it
weren't being made to the correct object.
neither of these solutions worked:
$newOb = &$this->newObject;
return &$newOb; /* still returns a copy of the object? */
or
return &$this->newObject; /* returns parse error */
so in this situation, how does one return a pointer to the newly created object
containted within a class, rather than a copy of it?
if I'm being terribly unclear, I'll try to create a smaller example of what I'm
doing in this revlatively large OO code I've been playing with.
shannon weyrick (weyrick@roadsend.com),