3v4l.org

run code in 300+ PHP versions simultaneously
<?php $f = "now"; $arr = array("date" => &$f, "timezone_type" => 3, "timezone" => new dummyclass()); echo "before call\n"; $d = DateTime::__set_state($arr); echo "after call\n"; echo $d->format('Y-m-d H:i:s'); class dummyclass { function __toString() { global $f; echo "converting\n"; $f = 0x0c00fee0; return "Europe/Paris"; } }
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
Fatal error: Uncaught Error: Class "dummyclass" not found in /in/KUZKi:5 Stack trace: #0 {main} thrown in /in/KUZKi on line 5
Process exited with code 255.
Output for 7.1.0 - 7.1.20, 7.2.0 - 7.2.33, 7.3.12 - 7.3.33, 7.4.0 - 7.4.33
before call Fatal error: Uncaught Error: Invalid serialization data for DateTime object in /in/KUZKi:8 Stack trace: #0 /in/KUZKi(8): DateTime::__set_state(Array) #1 {main} thrown in /in/KUZKi on line 8
Process exited with code 255.
Output for 5.4.38 - 5.4.45, 5.5.22 - 5.5.38, 5.6.6 - 5.6.30, 7.0.0 - 7.0.20
before call Fatal error: Invalid serialization data for DateTime object in /in/KUZKi on line 8
Process exited with code 255.
Output for 5.3.0 - 5.3.29, 5.4.0 - 5.4.37, 5.5.0 - 5.5.21, 5.6.0 - 5.6.5
before call converting
Process exited with code 139.
Output for 5.2.0 - 5.2.17
before call Fatal error: Call to undefined method DateTime::__set_state() in /in/KUZKi on line 8
Process exited with code 255.
Output for 5.0.0 - 5.0.5, 5.1.0 - 5.1.6
before call Fatal error: Class 'DateTime' not found in /in/KUZKi on line 8
Process exited with code 255.
Output for 4.3.2 - 4.3.11, 4.4.0 - 4.4.9
before call Fatal error: Undefined class name 'datetime' in /in/KUZKi on line 8
Process exited with code 255.
Output for 4.3.0 - 4.3.1
before call Fatal error: Undefined class name 'datetime' in /in/KUZKi on line 8

preferences:
233.14 ms | 401 KiB | 372 Q