* Brent Baisley <[EMAIL PROTECTED]>: > What is the best way to access one class from another? What I have is a > couple of "core" classes that are loaded into instances at the start of > each page. I then load instances of page specific classes. How would I > access the already loaded instances of the core classes from inside one > of the page specific classes? > > I tried a few things that didn't work. Is the only way to do this is to > load another instance of the core classes?
<snip> > I'm looking for something like this: > class Lists { > function UserList() { > } > ... > } > $coreLists = new Lists(); > ... > class Data { > function Entry() { > $users = $coreLists->UserList(); //Accessing Lists Class > ... > } > } Well, what comes to mind is to: * create an instance of Lists * pass that instance to Data when you instantiate a Data object (or later), and assign it to a property of Data. It'd look something like this: $coreLists = new Lists(); $coreData = new Data($coreLists); and in Data: class Data { function __construct(&$lists) { $this->lists =& $lists; } function Entry() { $users = $this->lists->UserList(); } } -- Matthew Weier O'Phinney | mailto:[EMAIL PROTECTED] Webmaster and IT Specialist | http://www.garden.org National Gardening Association | http://www.kidsgardening.com 802-863-5251 x156 | http://nationalgardenmonth.org -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php