About late static bindings
Read the PHP manual about the late static binding, or not quite understand, the original address http://cn2.php.net/manual/zh/language.oop5.late-static-bindings.php
A fourth example
PHP Code
The result is:
A
C
C
When calling to Parent::foo () and Self::foo (), why would I call the WHO () of Class C?
Which friend can explain, thank you.
------Solution--------------------
Explanation of the static operator:
late static binding attempts to bypass the restriction by introducing a keyword that represents the class that was originally called by the runtime.
And the class that was originally called is C.
A::foo (); Called a Class A method, which you understand
Self::foo (); This self is actually class C. Do you understand? C::test () c inherits the test () method of B
Parent::foo (); Due to static::who (); Rather than self::who (). The method calls the current class, which is the Foo () method of Class C
Maybe you still don't understand the WHO () method in Class A and why not call C, which is due to the special relationship of the parent. Lazy static binding is the only problem that occurs when you specifically resolve the inheritance method between subclasses and parent classes.
------Solution--------------------
It's not a very clear manual, is it?
------------------------------------------------------
Late binding means that static:: It is no longer parsed to define the class in which the current method resides, but is calculated at the actual run time. It can also be called a "static binding" because it can be used (but not limited to) the invocation of a static method.
-------------------------------------------------------
#1说的有个小问题
PHP Code