3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class Dad { public function early() { print __CLASS__ . PHP_EOL; } public function late() { print get_class($this) . PHP_EOL; } public static function called() { print get_called_class . PHP_EOL; } } class Child extends Dad {} $parent = new Dad(); $child = new Child(); print 'PARENT' . PHP_EOL; $parent->early(); $parent->late(); $parent->called(); print 'CHILD' . PHP_EOL; $child->early(); $child->late(); $child->called();
based on dZ7ll
Output for 7.2.0
PARENT Dad Dad Warning: Use of undefined constant get_called_class - assumed 'get_called_class' (this will throw an Error in a future version of PHP) in /in/vrfOL on line 11 get_called_class CHILD Dad Child Warning: Use of undefined constant get_called_class - assumed 'get_called_class' (this will throw an Error in a future version of PHP) in /in/vrfOL on line 11 get_called_class
Output for 5.3.20 - 7.1.10
PARENT Dad Dad Notice: Use of undefined constant get_called_class - assumed 'get_called_class' in /in/vrfOL on line 11 get_called_class CHILD Dad Child Notice: Use of undefined constant get_called_class - assumed 'get_called_class' in /in/vrfOL on line 11 get_called_class