Home>Article>Backend Development> The difference between php abstract methods and ordinary methods

The difference between php abstract methods and ordinary methods

王林
王林 Original
2019-10-12 17:58:21 3164browse

The difference between php abstract methods and ordinary methods

The main difference between abstract methods and ordinary methods is:

Abstract methods do not have a method body

What Is it a method body?

The method body is the code block of a method, that is, the part wrapped in curly braces.

Keywords for declaring abstract methods:

The keyword abstract is used to declare an abstract method

The difference between php abstract methods and ordinary methods

Other characteristics of abstract methods:

1. If a class contains an abstract method, the class must be declared as an abstract class

2. Abstract classes cannot be instantiated, but can only be inherited and implement all abstract methods of the abstract class

Summary of the use of abstract methods:

1. Abstract The method has no method body

2. The keyword abstract is used to declare an abstract method

3. The class containing the abstract method must be declared as an abstract class

4. Abstract classes cannot be instantiated

Recommended tutorial:PHP video tutorial

The above is the detailed content of The difference between php abstract methods and ordinary methods. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:What system is phpcms? Next article:What system is phpcms?