Re: Strange problem with objects

From: Date: Fri, 26 Jul 2002 02:42:11 +0000
Subject: Re: Strange problem with objects
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-109650@lists.php.net to get a copy of this message
On Wed, Jul 24, 2002 at 10:21:32PM -0400, Evan wrote: > > $document->session =& $session; > $session->document =& $document; Uh, this looks pretty weird. First, why assign the objects to each other by reference? The whole point of objects to be able to compartmentalize things and here you're breaking down the separation. Second, you assign session to document, but then you assign document to session. This means session will be reassigned to session. Overall, that seems quite wasteful. > $this is a <?=get_class($this)?><br> > $tihs->session is a <?get_class($this->session)?><br> > > Which returns: > > $this is a rj_document > $this->session is a Considering you're getting a blank result and you said $GLOBALS solves the problem, Im' guessing there's a scope problem. I strongly suggest you rethink your approach. Perhaps, if you need to access $session in $document functions, put a global $session; in the relevant $document functions, and vice versa. That'll keep things much cleaner. --Dan -- PHP classes that make web design easier SQL Solution | Layout Solution | Form Solution sqlsolution.info | layoutsolution.info | formsolution.info T H E A N A L Y S I S A N D S O L U T I O N S C O M P A N Y 4015 7 Av #4AJ, Brooklyn NY v: 718-854-0335 f: 718-854-0409

« previous php.general (#109650) next »