Abstract class and abstract method concepts and usage analysis in PHP, PHP abstraction
The examples in this article describe abstract classes and abstract methods in PHP. Share to everyone for your reference, as follows:
Abstract Key Words: Abstraction
Abstract is not an exact description, but there is a certain concept or name, in PHP to declare an abstract class or method we need to use the Adstract keyword.
II. definitions of abstract methods and abstract classes
At least one of the methods in a class is abstract, which we call abstract classes. So if you define an abstract class, you first define an abstract method.
Abstract class class1{ abstract function fun1 ();
1. There is at least one abstract method in the class
2. The abstract method does not allow {}
3. abstract methods must be added before
III. rules for the use of abstract classes and methods
Several features of abstract classes:
1, can not be instantiated, can only be inherited
2. inherit all abstract method overloads in the derived class to instantiate
Instance:
<?phpabstract class cl1{ abstract function fun1 (); Abstract function fun2 ();} Class Cl2 extends cl1{ function fun1 () { echo "first"; } function fun2 () { echo "second"; }} $c =new Cl2 (); Echo $c->fun2 ();? >
More about PHP related content readers can view the topic: "PHP File Operation Summary", "PHP operation and operator Usage Summary", "PHP Network Programming Skills Summary", "PHP Basic Grammar Introductory Tutorial", "PHP operation Office Document tips summary (including word, excel,access,ppt), "PHP Date and Time usage summary", "PHP primer for Object-oriented programming", "PHP String Usage Summary", "Getting Started with Php+mysql database operations" and "PHP Common Database Operations Skills Summary"
I hope this article is helpful to you in PHP programming.
http://www.bkjia.com/PHPjc/1133090.html www.bkjia.com true http://www.bkjia.com/PHPjc/1133090.html techarticle abstract class and abstract method concepts and usage analysis in PHP, PHP abstract This article describes the abstract classes and abstract methods in PHP. Share to everyone for your reference, specific as follows: First, abstract off ...