RE: [PHP4BETA] Re: [PHP3] Re: [PHP4BETA] Re: [PHP3] OO

From: Date: Tue, 10 Aug 1999 17:40:03 +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-3308@lists.php.net to get a copy of this message
There's no way of doing that (it's actually fairly bad OO design anyway, to return references to internals of your object, and have them manipulated in an uncontrolled manner; You can override this by directly accessing the object properties, though). Zeev At 17:53 10/08/99 , Shannon Weyrick wrote:
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), -- PHP 4 Beta
-- Zeev Suraski <zeev@zend.com> http://www.zend.com/ For a PGP public key, finger bourbon@netvision.net.il

« previous php.version4 (#3308) next »