() PHP, class inheritance

Source: Internet
Author: User

See the second section of the video on the 17th day of the Inheritance of class

So inheritance between classes is the creation of a new relationship, not the duplication of things from the parent class to subclasses---------------------

When you instantiate a class, call its method, first look at its own class there is no such method, if not found, to see whether the class has inherited the relationship, Eurasia is an inherited relationship, to find his father or above the class, if in his service or above the class found this method, This method will be implemented on this object.

But if you encounter a function like the name of the parent, this is called rewriting, but I think this is a new method definition, you see the steps to instantiate a class and implement the method, is to find their own, if they do not, and then to find the parent class, so, people in their own found, then directly use Ah, You don't have to look for a parent class at all.

Similarly, the property rewrite is also like this, is to see if your class has this attribute, if there is, directly use, if not go to the parent class there or above the class to find, eh,

() PHP, class inheritance

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.