3v4l.org

run code in 500+ PHP versions simultaneously
<?php $reflection = new ReflectionClass('\DateTime'); $mutable = $reflection->newInstanceWithoutConstructor(); $immutable = \DateTimeImmutable::createFromMutable($mutable);
Output for 7.4.0 - 7.4.33, 8.0.0 - 8.0.19, 8.1.0 - 8.1.6
Output for 8.0.20 - 8.0.30, 8.1.7 - 8.1.34, 8.2.0 - 8.2.34
Fatal error: Uncaught Error: The DateTime object has not been correctly initialized by its constructor in /in/gg0dq:6 Stack trace: #0 /in/gg0dq(6): DateTimeImmutable::createFromMutable(Object(DateTime)) #1 {main} thrown in /in/gg0dq on line 6
Process exited with code 255.
Output for 8.3.0 - 8.3.35, 8.4.1 - 8.4.26, 8.5.0 - 8.5.11
Fatal error: Uncaught DateObjectError: Object of type DateTime has not been correctly initialized by calling parent::__construct() in its constructor in /in/gg0dq:6 Stack trace: #0 /in/gg0dq(6): DateTimeImmutable::createFromMutable(Object(DateTime)) #1 {main} thrown in /in/gg0dq on line 6
Process exited with code 255.

preferences:
31.27 ms | 1151 KiB | 15 Q