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,624
  • 13
  • 41
  • 80

2 Answers2

11

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

meze
  • 14,975
  • 4
  • 47
  • 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,406
  • 9
  • 38
  • 57