Home >Backend Development >PHP Tutorial >A brief introduction to abstract methods, abstract classes and interfaces in PHP
This article brings you a brief introduction to abstract methods, abstract classes and interfaces in PHP. It has certain reference value. Friends in need can refer to it. I hope it will be useful to you. Helps.
Abstract method
abstract function say();
Abstract class
abstract class Person{ abstract function say(); }
1. Abstract classes cannot be instantiated
2 . Abstract classes can have abstract methods
3. Subclasses must implement abstract methods
Interface
1. All methods in the interface It is an abstract method
2. The interface attribute must be a constant
3. It must be public
4.Interface declaration
interface Demo{ const NAME=’ngyhd’; function test();}
Related recommendations:
Code examples of non-forwarding calls and forwarding calls in php
How to implement the page jump function in PHP? (Function label example)
The above is the detailed content of A brief introduction to abstract methods, abstract classes and interfaces in PHP. For more information, please follow other related articles on the PHP Chinese website!