PHP workaround for multiple inheritance?
I know PHP doesn't support multiple inheritance. But I need a way to use functions between two or more classes:
Code:
class one I also heard some people about using interfaces. But when you use interfaces, you still need to define the functions in each class. So how should i do a workaround for multiple inheritance in PHP? |
No direct answer
It really depends on what exactly you are doing as to what will make sense. Can you make any of the functions static?
http://us.php.net/manual/en/language.oop5.static.php Can something be made into a singleton? Check out some design patterns with php. http://www.ibm.com/developerworks/li...p-designptrns/ |
And to a certain extent, "a language is what a language is..."
|
You can tackle this through association. Have an instance of class one in class two and then you will be able to do $this->one->test1();
|
All times are GMT -5. The time now is 12:36 AM. |