5

Can I extend a PHP class from two classes, one of which is abstract and other one is not? like:

class customer extends SomeControllerClass implements SomeAbstractClass {
...
}

the reason to do is that I have my commonly used functions and logic in the abstract class.

Firdous
  • 4,564
  • 12
  • 39
  • 76

2 Answers2

11

No. But there are traits in PHP 5.4 that you can use for that.

meze
  • 14,706
  • 4
  • 46
  • 52
4

Think about this: do you only want inheritance for reusability, or is there an is-a relationship? if it is just the former, then delegation is a better solution. For the latter you will need to use interfaces and probably delegation again to achieve this. So the answer is use delegation.

Robert
  • 8,108
  • 8
  • 35
  • 56