Analysis of php delayed static binding instances and delayed static instance analysis. Php delayed static binding instance analysis, delayed static instance analysis this article describes the php delayed static binding method. Share it with you for your reference. The specific analysis is as follows: Analysis of php delayed static binding instances, analysis of delayed static instances
This article describes how to delay static binding in php. Share it with you for your reference. The specific analysis is as follows:
Php delayed static binding: refers to the class self, which is not defined at the time of definition, but the running result at the time of calculation. First look at an instance
<? Phpheader ("content-type: text/html; charset = utf-8"); class Human {public static function hei () {echo "I am the hei () of the parent class () method ";} public function say () {// if the subclass calls the say () method of the parent class, then self: hei (); // The hei () method of the parent class is called here static: hei (); // The hei () method of the subclass is called here. if The hei () method does not exist in the subclass, then the class Stu extends Human {public static function hei () {echo "I am the hei () method of the subclass" ;}} of the parent class is called ";}} $ stu = new Stu (); $ stu-> say ();?>
Note:
(1) when the subclass instantiate object $ stu calls the say method, it runs in the parent class Human. Therefore, self: hei () in say () is to call the hei () method of the parent class.
(2) static: method name (): If you use the static keyword, you first need to find the method in the subclass. if you cannot find the method, you can find it in the parent class.
I hope this article will help you with php programming.
The example in this article describes how to delay static binding in php. Share it with you for your reference. The specific analysis is as follows: php latency static...