3v4l.org

run code in 300+ PHP versions simultaneously
<?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();
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
PARENT Dad Dad Fatal error: Uncaught Error: Undefined constant "get_called_class" in /in/vrfOL:11 Stack trace: #0 /in/vrfOL(23): Dad::called() #1 {main} thrown in /in/vrfOL on line 11
Process exited with code 255.
Output for 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33
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.5.0 - 5.5.38, 5.6.0 - 5.6.40, 7.0.0 - 7.0.33, 7.1.0 - 7.1.33
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

preferences:
264.6 ms | 403 KiB | 330 Q