How you can you use an object that is already an instance? -----Original Message----- From: John Wells [mailto:[EMAIL PROTECTED]] Sent: Sunday, February 09, 2003 4:21 PM To: [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Subject: Re: [PHP] Object In a class
Justin Mazzi said: > Can anyone tell me how to use an object within an object. Example > > > class blah { > var $test; > var $test2; > > function test() { > $this->do(); > } > > } > > > then you want to use that class in a new one. > > > class blah2 { > var $test; > var $test2; > > function do() { > $blah = new blah(); > } > > } > Well, you could use the blah object you created exclusively in function do(), or you could create it as a attribute of your class and use it in your instantiated objects, as: class blah2 { var $test; var $test2; var $myBlah; function blah2() { $this->myBlah = new blah(); } function do() { $this->myBlah->test(); } } $myobj = new blah2(); $myobj->do(); -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php