3v4l.org

run code in 300+ PHP versions simultaneously
<?php class CustomDateTime extends \DateTime {} $dts = serialize(new \DateTime()); $dtis = serialize(new \DateTimeImmutable()); $cdts = serialize(new \CustomDateTime()); echo get_class(unserialize($dts, ['allowed_classes' => [\DateTime::class]])) . PHP_EOL; echo get_class(unserialize($dtis, ['allowed_classes' => [\DateTime::class]])) . PHP_EOL; echo PHP_EOL; echo get_class(unserialize($dts, ['allowed_classes' => [\DateTimeImmutable::class]])) . PHP_EOL; echo get_class(unserialize($dtis, ['allowed_classes' => [\DateTimeImmutable::class]])) . PHP_EOL; echo PHP_EOL; echo get_class(unserialize($dts, ['allowed_classes' => [\DateTimeInterface::class]])) . PHP_EOL; echo get_class(unserialize($dtis, ['allowed_classes' => [\DateTimeInterface::class]])) . PHP_EOL; echo PHP_EOL; echo get_class(unserialize($cdts, ['allowed_classes' => [\DateTime::class]])) . PHP_EOL; echo get_class(unserialize($cdts, ['allowed_classes' => [\DateTime::class]])) . PHP_EOL;
Output for 7.2.0 - 7.2.34, 7.3.0 - 7.3.25, 7.4.0 - 7.4.13, 8.0.0
DateTime __PHP_Incomplete_Class __PHP_Incomplete_Class DateTimeImmutable __PHP_Incomplete_Class __PHP_Incomplete_Class __PHP_Incomplete_Class __PHP_Incomplete_Class