Re: Object In Object

From: Date: Thu, 09 Dec 2004 19:27:49 +0000
Subject: Re: Object In Object
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-203853@lists.php.net to get a copy of this message
* Dinçer akay <dincer@sikayetvar.com>: > Is this a good way ? > <? > > class main{ > var $mysql; > var $user; > function main(){ > $this->mysql=new mysql(); > $this->user=new user(); If you're developing strictly for PHP5, this will work fine. However, if you're in PHP4, you're going to want to use references. Try the following: $mysql =& new mysql(); $this->mysql =& $mysql; $user =& new user(); $this->user =& $user; Other than that, yes, this is a fairly standard mechanism in PHP's OOP. -- Matthew Weier O'Phinney | mailto:matthew@garden.org Webmaster and IT Specialist | http://www.garden.org National Gardening Association | http://www.kidsgardening.com 802-863-5251 x156 | http://nationalgardenmonth.org

« previous php.general (#203853) next »