: This article mainly introduces the latency static binding of new features of php53. For more information about PHP tutorials, see. PHP-based version: 5.3.5
After PHP5.3, delayed static binding is introduced:
Static (keyword) is similar to self, but it points to the called class (Document) instead of the containing class (DomainObject), the difference between static and self:
The main function is to make up for the original shortcomings. the original child class can use parent to find the parent class object. now, the child class can use static to find the child class object that inherits it.
class A { public static function echoClass() { echo __CLASS__; }
public function what(){ echo __CLASS__;}
Public static function test (){$ This-> what (); // output B
Static: echoClass (); // output B self: echoClass (); // output A} class B extends A {public static function echoClass () {echo _ CLASS __;}} B: test ();Self is the object of the current class, static is the object of the called class, $ this is the object of the currently called class, but $ this cannot call static attributes, self can, _ CLASS _ is used to specify the name of a CLASS. it is generally used to register a CLASS.
class B extends A { public static function echoClass($name=1) { spl_autoload_register(array(__CLASS__,"echoClass")); echo __CLASS__; } }
Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.
The above introduces the new features of php53, including the delayed static binding, and hopes to be helpful to friends who are interested in PHP tutorials.