Does php5.3.1 support multi-inheritance? In the past, php did not support multi-inheritance. now it supports multi-inheritance.
During the learning process, I have no intention to find the following phenomena:
Class {
Function X (){
Echo 'y ';
}
Function test (){
Echo "df ";
}
}
Class B extends {
Function Y (){
Echo parent: X ();
}
}
Class C extends B {
Function Z (){
Echo parent: Y ();
}
}
$ C = new C ();
$ C-> X ();
$ C-> test ();
?>
Output result: ydf
Reply to discussion (solution)
This is not multi-inheritance.
Ah, it turns out so. But in the past, it seems that my grandson could not inherit Grandpa's family, right? Cainiao, haha .......
It hurts ~ I thought php could really inherit more !!
PHP does not support multi-inheritance. it supports single-inheritance. if you must implement multi-inheritance, you can use interfaces to implement multi-inheritance in the tutorial.
This is still a single inheritance.
I'm dizzy. Is this an inheritance?
Compared with multi-inheritance, it is better to use interfaces.
This is the relationship between grandpa, dad, and son. how can we inherit more ???
I really think that multi-inheritance can be implemented. Multi-inheritance inherits Class A from class B and Class C.
This is also called single inheritance ???????? It's the title of the second generation.
Multi-inheritance means that the four sons inherit the relationship of one father and map the relationship. while single-inheritance means one inheritance, which is like linear inheritance, the last one inherits all the previous attributes and methods.