drkstr Posted September 7, 2006 Share Posted September 7, 2006 Any advice?thanks!...drkstr Link to comment https://forums.phpfreaks.com/topic/20039-solved-how-can-i-extend-multiple-classes/ Share on other sites More sharing options...
obsidian Posted September 7, 2006 Share Posted September 7, 2006 can you be more specific? if you're looking to have one class that extends multiple ones, it ain't gonna happen. however, if you're wanting to simply extend multiple levels, you can just continue lik this:[code]<?phpclass Organism { var $distinction; function Organism($distinction) { $this->distinction = $distinction; }}class Person extends Organism { function Person() { parent::Organism("Human"); }}class User extends Person { var $username; function User($username) { parent::Person(); $this->username = $username; }}?>[/code]at least, i think i got all my references correct :P ... coding on the fly lends itself to errors!hope this helps Link to comment https://forums.phpfreaks.com/topic/20039-solved-how-can-i-extend-multiple-classes/#findComment-87925 Share on other sites More sharing options...
drkstr Posted September 7, 2006 Author Share Posted September 7, 2006 Darn, I guess it's not going to happen then. I have a data template and a service template and I wanted to extend them both into an actual "library" object which is customized for it's actual use. I'm going to have a *lot* of these objects, so I was trying to get around rewriting the same code over and over. I gues I will just extend the service template and make an isntance of the data object in the child. The data template doesn't have that much code, and the only thing that will change in the service template is the name of the class, so I guess it would make sence to just get rid of the data template and just duplicate the code in each of the data objects.Thanks for the quick reply!...drkstr Link to comment https://forums.phpfreaks.com/topic/20039-solved-how-can-i-extend-multiple-classes/#findComment-87968 Share on other sites More sharing options...
obsidian Posted September 7, 2006 Share Posted September 7, 2006 so... why not create a third class that has member variables that are actually instances of the first two objects? then, you could write member functions that would access given portions of either of the other two classes and [b]act[/b] as though you had joined the classes into one.make sense? Link to comment https://forums.phpfreaks.com/topic/20039-solved-how-can-i-extend-multiple-classes/#findComment-87972 Share on other sites More sharing options...
drkstr Posted September 8, 2006 Author Share Posted September 8, 2006 Ahh, That's a great idea! I'll just change the protected data/methods to public, and I'll be good to go.Thanks for the help!...drkstr Link to comment https://forums.phpfreaks.com/topic/20039-solved-how-can-i-extend-multiple-classes/#findComment-88106 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.