3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foobar implements \Serializable { /** @return string */ public function serialize(): string { return serialize(new \DateTimeZone('Europe/Andorra')); } /** @param string $serialized */ public function unserialize($serialized) { var_dump($serialized); var_dump(unserialize($serialized)->getName()); } } (new Foobar())->unserialize((new Foobar())->serialize()); var_dump(unserialize(serialize(new Foobar())));
Output for 8.3.0 - 8.3.4, 8.3.6
Deprecated: Foobar implements the Serializable interface, which is deprecated. Implement __serialize() and __unserialize() instead (or in addition, if support for old PHP versions is necessary) in /in/QEdfQ on line 3 string(86) "O:12:"DateTimeZone":2:{s:13:"timezone_type";i:3;s:8:"timezone";s:14:"Europe/Andorra";}" string(14) "Europe/Andorra" string(86) "O:12:"DateTimeZone":2:{s:13:"timezone_type";i:3;s:8:"timezone";s:14:"Europe/Andorra";}" Fatal error: Uncaught DateObjectError: Object of type DateTimeZone has not been correctly initialized by calling parent::__construct() in its constructor in /in/QEdfQ:15 Stack trace: #0 /in/QEdfQ(15): DateTimeZone->getName() #1 [internal function]: Foobar->unserialize('O:12:"DateTimeZ...') #2 /in/QEdfQ(20): unserialize('C:6:"Foobar":86...') #3 {main} thrown in /in/QEdfQ on line 15
Process exited with code 255.
Output for 8.3.5
Warning: PHP Startup: Unable to load dynamic library 'sodium.so' (tried: /usr/lib/php/8.3.5/modules/sodium.so (libsodium.so.23: cannot open shared object file: No such file or directory), /usr/lib/php/8.3.5/modules/sodium.so.so (/usr/lib/php/8.3.5/modules/sodium.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0 Deprecated: Foobar implements the Serializable interface, which is deprecated. Implement __serialize() and __unserialize() instead (or in addition, if support for old PHP versions is necessary) in /in/QEdfQ on line 3 string(86) "O:12:"DateTimeZone":2:{s:13:"timezone_type";i:3;s:8:"timezone";s:14:"Europe/Andorra";}" string(14) "Europe/Andorra" string(86) "O:12:"DateTimeZone":2:{s:13:"timezone_type";i:3;s:8:"timezone";s:14:"Europe/Andorra";}" Fatal error: Uncaught DateObjectError: Object of type DateTimeZone has not been correctly initialized by calling parent::__construct() in its constructor in /in/QEdfQ:15 Stack trace: #0 /in/QEdfQ(15): DateTimeZone->getName() #1 [internal function]: Foobar->unserialize('O:12:"DateTimeZ...') #2 /in/QEdfQ(20): unserialize('C:6:"Foobar":86...') #3 {main} thrown in /in/QEdfQ on line 15
Process exited with code 255.
Output for 8.1.0 - 8.1.28, 8.2.0 - 8.2.18
Deprecated: Foobar implements the Serializable interface, which is deprecated. Implement __serialize() and __unserialize() instead (or in addition, if support for old PHP versions is necessary) in /in/QEdfQ on line 3 string(86) "O:12:"DateTimeZone":2:{s:13:"timezone_type";i:3;s:8:"timezone";s:14:"Europe/Andorra";}" string(14) "Europe/Andorra" string(86) "O:12:"DateTimeZone":2:{s:13:"timezone_type";i:3;s:8:"timezone";s:14:"Europe/Andorra";}" Fatal error: Uncaught Error: The DateTimeZone object has not been correctly initialized by its constructor in /in/QEdfQ:15 Stack trace: #0 /in/QEdfQ(15): DateTimeZone->getName() #1 [internal function]: Foobar->unserialize('O:12:"DateTimeZ...') #2 /in/QEdfQ(20): unserialize('C:6:"Foobar":86...') #3 {main} thrown in /in/QEdfQ on line 15
Process exited with code 255.
Output for 8.0.0 - 8.0.30
string(86) "O:12:"DateTimeZone":2:{s:13:"timezone_type";i:3;s:8:"timezone";s:14:"Europe/Andorra";}" string(14) "Europe/Andorra" string(86) "O:12:"DateTimeZone":2:{s:13:"timezone_type";i:3;s:8:"timezone";s:14:"Europe/Andorra";}" Fatal error: Uncaught Error: The DateTimeZone object has not been correctly initialized by its constructor in /in/QEdfQ:15 Stack trace: #0 /in/QEdfQ(15): DateTimeZone->getName() #1 [internal function]: Foobar->unserialize('O:12:"DateTimeZ...') #2 /in/QEdfQ(20): unserialize('C:6:"Foobar":86...') #3 {main} thrown in /in/QEdfQ on line 15
Process exited with code 255.
Output for 7.0.15 - 7.0.33, 7.1.1 - 7.1.33, 7.2.0 - 7.2.34, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33
string(86) "O:12:"DateTimeZone":2:{s:13:"timezone_type";i:3;s:8:"timezone";s:14:"Europe/Andorra";}" string(14) "Europe/Andorra" string(86) "O:12:"DateTimeZone":2:{s:13:"timezone_type";i:3;s:8:"timezone";s:14:"Europe/Andorra";}" Warning: DateTimeZone::getName(): The DateTimeZone object has not been correctly initialized by its constructor in /in/QEdfQ on line 15 bool(false) object(Foobar)#1 (0) { }
Output for 7.0.0 - 7.0.14, 7.1.0
string(86) "O:12:"DateTimeZone":2:{s:13:"timezone_type";i:3;s:8:"timezone";s:14:"Europe/Andorra";}" string(14) "Europe/Andorra" string(86) "O:12:"DateTimeZone":2:{s:13:"timezone_type";i:3;s:8:"timezone";s:14:"Europe/Andorra";}" string(14) "Europe/Andorra" object(Foobar)#1 (0) { }
Output for 5.6.0 - 5.6.40
Parse error: syntax error, unexpected ':', expecting ';' or '{' in /in/QEdfQ on line 6
Process exited with code 255.

preferences:
223.71 ms | 401 KiB | 298 Q