Home > Article > Backend Development > 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
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!