Abstract classes and abstract methods in PHP

Source: Internet
Author: User

Characteristics:

1: A class that is defined as abstract and cannot be instantiated;

2: Any class if there is at least one method within it that is declared abstract;

3: is defined as an abstract method, only the method body (including parameters), there is no specific implementation process;

4: When a subclass inherits the abstract parent class, the subclass must implement all the abstract methods in the parent class, and the access control of the abstract method must be the same as the parent class, (or looser);

For example:abstract protected function test (); When the modifier of the parent class's abstract method is protected, the implementation of its subclass method must be a modifier of: protected or public, not private;

5: If an optional parameter is defined in the abstract method of the parent class, an optional parameter must also be defined in the subclass, and when the optional argument of the parent class is one, the optional parameters of the subclass are at least one, or two, three., and the subclass is defined in the sub-class.

An optional parameter, which can be undefined or defined in the parent class;

Abstract classes and abstract methods in PHP

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.