In the OOP language, a class can have one or more subclasses, and each class has a public method to access its interface as an external code. Abstract methods are introduced to facilitate inheritance.
Master 2 Why?
What is an abstract method?
The method defined in the class without the method body is an abstract method, and the so-called no method body refers to the absence of curly braces and the contents of the method declaration. Instead, simply add a semicolon to the method name to end it. In addition, when declaring an abstract method, add a keyword abstract to decorate it.
What is an abstract class?
As long as there is one method in a class that is abstract, the class is defined as an abstract class, and the abstract class uses the keyword modifier (abstract)
Remember that this class must be declared as an abstract class as long as one method is an abstract method.
Abstract class Demo{public $name; Abstruct function CheckUser (); Abstruct function Checkpassword ();}
Note: Abstract classes cannot produce instance objects, so they cannot be used directly.
Abstract methods are used as subclasses of overloaded templates, the definition of abstract class equivalent to define a specification, which requires subclasses to obey, subclass inherits abstract class, the abstract class inside the abstract methods are all implemented, otherwise there are abstract methods in the subclass, then the subclass or abstract class, or can not instantiate class
Abstract method is to subclass the use of inheritance, the definition of abstract class equivalent to define a specification, the specification subclass must be strictly enforced, subclass inherits abstract class, the abstract class inside the abstract method of all implementation, indispensable. You can instantiate only if you have finished writing it all.
PHP Object-oriented abstract class