Jump to content

Multiple inheritance in PHP


renatov

Recommended Posts

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.