Home >Backend Development >PHP Tutorial >PHP53 new feature delayed static binding
class A { public static function echoClass() { echo __CLASS__; }
public function what(){ echo __CLASS__;}
public static function test() { <pre name="code" class="php"> $this->what(); //输出Bstatic::echoClass(); //Output B self::echoClass(); //Output A } } class B extends A { public static function echoClass() { echo __CLASS__; } } B::test( );
static refers to the object of the calling class, $this also refers to the object of the currently calling class, but $this cannot To call static attributes, self can be used, and __CLASS__ is used to specify the name of the class, which is generally used to register the class method.
class B extends A { public static function echoClass($name=1) { spl_autoload_register(array(__CLASS__,"echoClass")); echo __CLASS__; } }
Copyright Statement: This article is an original article by the blogger and may not be reproduced without the blogger's permission.
The above has introduced the new feature of php53, delayed static binding, including aspects of it. I hope it will be helpful to friends who are interested in PHP tutorials.