What is an abstract method? The method that we define in the class without the method body is an abstract method. The so-called no method body refers to the method declaration when there is no curly braces and the contents of it, but directly at the declaration of the method name after the end of the semicolon, and in the declaration of the abstract method also add a keyword "abstract" to decorate.
Catalogue ====================================
1. Declaring an abstract class, abstract method (case one)
2. Inheriting an abstract class (instance two)
=======================================
Case One
<? Abstract class test{ // declares a test abstract class public $name ; Abstract Public // declaring an abstract method Public ?>
Example Two
<?PHPAbstract classhello{Abstract Publicfunction Test ();}/*** */classNihao extends hello{ Publicfunction Test () {echo"Hello world\n"; }}/*** */classWohao extends hello{ Publicfunction Test () {echo"I want to become Daniel! "; }} $a=NewNihao; $a-test ();?>
The output reads as follows:
Hello World
The END
Follow Baidu Learn Php[4]oop face Object Programming -12-abstract class