Late Static Binding¶
PHP implements a feature called late static bindings which can be used to reference the called class in a context of static inheritance.
<?php
class A {
public static function who() {
echo __CLASS__;
}
public static function test() {
static::who(); // Here comes Late Static Bindings
}
}
class B extends A {
public static function who() {
echo __CLASS__;
}
}
B::test();
?>
See also Late static binding in PHP - What, How & When, A real life example of using Late Static Binding in PHP, Example of using Late Static Binding in PHP
Related : Self, static, parent, Early Binding