views:

159

answers:

2

Hi,

I read about this ages ago but never tried it now I can't remember if this is possible or not. Is it possible to extend a class from two parents on php5 e.g.

class_d extends class_c and class_b

moreover can you do this if class_c and class_b are themselves extended from class_a ... so you get something like this

                          class_a
                  class_b          class_c
                          class_d
+3  A: 

multiple inheritance (what you are looking for) is not supported in PHP.

You may want to check out composition (where one class contains an instance of the parent) or even interfaces if it applies specifically to your situation.

StingyJack
And returning the favor.
Loki
+3  A: 

What you want is called multiple inheritance. It doesn't exist in PHP.

Alternatives exist though: Composition, A parent could inherit the other, mixins and maybe more...

From: http://www.phpbuilder.com/board/showthread.php?t=10351110

Loki
+1 for thinking alike.
StingyJack