renatov Posted February 6, 2014 Share Posted February 6, 2014 Why isn't there multiple inheritance in PHP? Is there any particular reason? Quote Link to comment https://forums.phpfreaks.com/topic/285979-multiple-inheritance-in-php/ Share on other sites More sharing options...
requinix Posted February 6, 2014 Share Posted February 6, 2014 Any particular reason? Probably not. But a combination of reasons may play a part, such as - Rarely ever makes sense in an true OOP sense. When used it generally violates the idea that a class represents an entity by making a class encapsulate functionality, such as adding database connectivity or providing a "default" implementation for an interface. - Ambiguity of having multiple parents. Like, if two parents both inherit from one single ancestor and each override a particular method, which implementation does a child receive? - Lack of a need. PHP has traits which allows you to "import" functions into classes as if they were written natively. (The concept is also called "mixins".) - Awkwardness. How do you refer to a particular parent from a child? parent won't work as-is and you can't use the parent class's name as that looks like a static method call. Quote Link to comment https://forums.phpfreaks.com/topic/285979-multiple-inheritance-in-php/#findComment-1467912 Share on other sites More sharing options...
renatov Posted February 9, 2014 Author Share Posted February 9, 2014 I see, thanks for your explanation, it clarifies some things to me! Quote Link to comment https://forums.phpfreaks.com/topic/285979-multiple-inheritance-in-php/#findComment-1468230 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.