What is the main difference between abstract methods and ordinary methods in php

王林
Release: 2023-02-28 18:02:01
forward
5054 people have browsed it

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)

What is the main difference between abstract methods and ordinary methods in php

##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:

php tutorial

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!

Related labels:
source:jb51.net
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template