I don't get how this late static binding works.
abstract class A{
final public static function doprint(){
print get_called_class() . '<br>';
}
public static function wrapper(){
self::doprint();
static::doprint();
}
}
class A2 extends A{}
A2::wrapper();
get_called_class() prints A2 in both cases, even when I called the doprint method with self. why?
get_called_class() always returns the class you actually call. You call A2:: so it's A2.
On my site there's a tutorial with an LSB singleton abstract class. I'm not linking here because there's always a zombie vigilante that comes and removes the links without even looking. But it's in my description.
The catch with LSB is that a method in A can call a method in B which can call a method in A back. See this example:
See how B::TriggerStatic() allows A to call a B method while B::TriggerSelf() calls a A method. That's LSB. Parent class static methods can call child class static methods. It's pretty much static abstracts :)
Study the example, it'll make sense.