3v4l.org

run code in 300+ PHP versions simultaneously
<?php var_dump(serialize((new \ReflectionClass(\DateTime::class))->newInstanceWithoutConstructor()));
Output for 8.3.0 - 8.3.30, 8.4.1 - 8.4.18, 8.5.0 - 8.5.3
Fatal error: Uncaught DateObjectError: Object of type DateTime has not been correctly initialized by calling parent::__construct() in its constructor in /in/MIlqB:3 Stack trace: #0 [internal function]: DateTime->__serialize() #1 /in/MIlqB(3): serialize(Object(DateTime)) #2 {main} thrown in /in/MIlqB on line 3
Process exited with code 255.
Output for 8.2.0 - 8.2.30
Fatal error: Uncaught Error: The DateTime object has not been correctly initialized by its constructor in /in/MIlqB:3 Stack trace: #0 [internal function]: DateTime->__serialize() #1 /in/MIlqB(3): serialize(Object(DateTime)) #2 {main} thrown in /in/MIlqB on line 3
Process exited with code 255.
Output for 5.6.0 - 5.6.28, 7.0.0 - 7.0.20, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.34
string(19) "O:8:"DateTime":0:{}"
Output for 5.5.0 - 5.5.36
Fatal error: Uncaught exception 'ReflectionException' with message 'Class DateTime is an internal class that cannot be instantiated without invoking its constructor' in /in/MIlqB:3 Stack trace: #0 /in/MIlqB(3): ReflectionClass->newInstanceWithoutConstructor() #1 {main} thrown in /in/MIlqB on line 3
Process exited with code 255.

preferences:
100.92 ms | 1779 KiB | 4 Q