Home > Article > Backend Development > What is the main difference between abstract methods and ordinary methods in php
The main difference between abstract methods and ordinary methods:
Abstract methods do not have a method body.
Supplement:
What is 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.
As shown: (Recommended learning video: php video tutorial)
##Other features of abstract methods:
1. If a class contains abstract methods, the class must be declared as an abstract class; 2. Abstract classes cannot be instantiated, but can only be inherited and implement the abstraction. All abstract methods of the class.Summary of the use of abstract methods:
1. Abstract methods have no method body; 2. The keyword abstract is used to declare an abstract method; 3. Classes containing abstract methods must be declared as abstract classes; 4. Abstract classes cannot be instantiated. Related article tutorial sharing:The above is the detailed content of What is the main difference between abstract methods and ordinary methods in php. For more information, please follow other related articles on the PHP Chinese website!