Does php5.3.1 support multi-inheritance?

Source: Internet
Author: User
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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.