php5.3 version of the static binding of the new static binding syntax, also become late static binding PHP, as follows
classa{ Public Static functionfunc1 () {Echo __class__.Php_eol; } Public Static functionTest () { self::func1 (); } }classB Extend a{ Public Static functionfunc1 () {Echo __class__.Php_eol;//__class__ is the name of the current class}}b::test (); Result: A
But, since B inherits a and rewrites the func1 of a, what do you want to do with func1 in Test B? Therefore, php5.3 uses the reserved static keyword to change the test function in the above code to this:
Public Static function Test () { static::
结果:B
In other words: static:: The implementation of the late statically bound, static:: The corresponding variable is no longer the current class of variables, but by the final operation when the dynamic decision (also can be said from the heap extracted from the keyword).
At the same time, in this learning process, I also found another use: New Static () and new Self (), as well, new static is the instantiation of the final class, and new self is to instantiate the current class, new parent is the implementation of the current class of the parent class.
Okay, by the way. There are three ways to use this format: "Self::", "Parent::", "Static::";
"Go" late static bindings in PHP (late static Bindings)