Without understanding any additional context here, you don't need to actually invoke get_called_class
to poke at LSB-resolved static properties. Instead, use the static
keyword to automagically resolve the currently called static class name.
class A {
static $foo = 'from a';
public static function test($property) {
echo static::$$property, "\n";
}
}
class B extends A { static $foo = 'from b'; }
class C extends A { static $foo = 'from c'; }
Example from the PHP interactive prompt:
php > include '/tmp/get_called_class.php'; php > A::test('foo'); from a php > B::test('foo'); from b php > C::test('foo'); from c php >