Php class inheritance _ PHP Tutorial

Source: Internet
Author: User
Class inheritance in php. In php, class inheritance 1. subclass inherits the parent class using the extends keyword 2. subclass can only inherit from one parent class, but the parent class can inherit from another class 3. when inheriting, it can inherit the class inheritance in the common php of the parent class.
1. subclass inherits the extends keyword used by the parent class

2. subclass can only inherit from one parent class, but the parent class can inherit from another class

3. during inheritance, you can inherit the public/protected attributes and methods of the parent class, and cannot inherit private attributes and methods.

4. in child classes, attributes and methods with the same name as the parent class can be declared to be overwritten. However, the inherited permissions can only be the same or become looser and stricter, for example, if the parent class declares protected $ a, private $ a cannot be declared in the subclass, and public or protected can only be used.

Parent 1. the subclass inherits the parent class with the extends keyword 2. the subclass can only inherit from one parent class, but the parent class can inherit from another class 3, it can inherit the public... of the parent class...

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.