3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class RootClass { public static function getStaticName() { echo 'get_called_class(): ' . get_called_class(). "\n"; echo 'static::$class: ' . static::$class . "\n"; } public function getName() { static::getStaticName(); } } class SubClass extends RootClass {} $instance = new SubClass(); $instance::getStaticName();
based on AHYjG
Output for 7.0.0 - 7.3.1
get_called_class(): SubClass Fatal error: Uncaught Error: Access to undeclared static property: SubClass::$class in /in/c24ea:6 Stack trace: #0 /in/c24ea(16): RootClass::getStaticName() #1 {main} thrown in /in/c24ea on line 6
Process exited with code 255.
Output for 5.6.0 - 5.6.24
get_called_class(): SubClass Fatal error: Access to undeclared static property: SubClass::$class in /in/c24ea on line 6
Process exited with code 255.