PHP abstract class use points and considerations analysis, PHP abstract
This article analyzes the use of PHP abstract class points and considerations. Share to everyone for your reference. The specific analysis is as follows:
PHP abstract class use points and considerations are as follows:
1, using abstract to modify a class, then this class is abstract class, abstract class can never be instantiated, that is, $ABC = new abstract class name (); error.
2, using abstract to modify a method, then the method is an abstract method;
3, if there is an abstract method in the class, then the class must be defined as an abstract class, but in turn, abstract classes do not necessarily have abstract methods. In addition, abstract classes can also have common methods.
4, abstract methods can not have method body. That is, abstract function abc ();------cannot be appended with parentheses {...}.
5. A class inherits an abstract class, so it must implement all the abstract methods in the abstract class (unless it is also declared abstract, which is equivalent to an abstract class inheriting an abstract class).
Abstract class Simple example:
<?phpabstract class animal{public $name; protected $price; abstract function Cry ();} Class Dog extends animal{function cry () {echo "Barking ...";}} $ABC = new Animal ();? >
I hope this article is helpful to everyone's PHP programming.
http://www.bkjia.com/PHPjc/955402.html www.bkjia.com true http://www.bkjia.com/PHPjc/955402.html techarticle PHP abstract class use points and considerations for analysis, PHP abstract This article analyzes the use of PHP abstract class points and considerations. Share to everyone for your reference. The specific analysis is as follows: Php pumping ...