Use get_called_class()
instead of __CLASS__
. You can also replace static
with self
, since the function will allow the class through late binding for you:
class A { public static function who() { echo get_called_class(); } public static function test() { self::who(); } } class B extends A {} B::test();
source share