3v4l.org

run code in 300+ PHP versions simultaneously
<?php class A {} class B extends A {} $b = new B(); echo get_parent_class($b); get_class('Character'); $name = 'Character'; $arguments = array(); $reflect = new \ReflectionClass($name); print_r($reflect); print_r($name); print_r($arguments); $o = $reflect->newInstanceArgs($arguments);
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
A Fatal error: Uncaught TypeError: get_class(): Argument #1 ($object) must be of type object, string given in /in/mSgQA:10 Stack trace: #0 {main} thrown in /in/mSgQA on line 10
Process exited with code 255.
Output for 7.0.0 - 7.0.33, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33
A Warning: get_class() expects parameter 1 to be object, string given in /in/mSgQA on line 10 Fatal error: Uncaught ReflectionException: Class Character does not exist in /in/mSgQA:15 Stack trace: #0 /in/mSgQA(15): ReflectionClass->__construct('Character') #1 {main} thrown in /in/mSgQA on line 15
Process exited with code 255.
Output for 5.3.0 - 5.3.29, 5.4.0 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.40
A Warning: get_class() expects parameter 1 to be object, string given in /in/mSgQA on line 10 Fatal error: Uncaught exception 'ReflectionException' with message 'Class Character does not exist' in /in/mSgQA:15 Stack trace: #0 /in/mSgQA(15): ReflectionClass->__construct('Character') #1 {main} thrown in /in/mSgQA on line 15
Process exited with code 255.

preferences:
253.84 ms | 402 KiB | 404 Q