3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo { public function __sleep() { return []; } public function __wakeup() { echo 'Called ' . __METHOD__ . PHP_EOL; } } class Bar implements \Serializable { private $foo; public function __construct(Foo $foo) { $this->foo = $foo; } public function serialize() { return serialize($this->foo); } public function unserialize($serialized) { echo 'unserialize Foo' . PHP_EOL; $this->foo = unserialize($serialized); echo 'end unserialize Foo' . PHP_EOL; } } $foo = new Foo(); $bar = new Bar($foo); $barStr = serialize($bar); $newBar = unserialize($barStr);
Output for 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.4, 8.3.6
Deprecated: Bar 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/MlbuO on line 15 unserialize Foo end unserialize Foo Called Foo::__wakeup
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: Bar 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/MlbuO on line 15 unserialize Foo end unserialize Foo Called Foo::__wakeup
Output for 5.6.30 - 5.6.40, 7.0.15 - 7.0.33, 7.1.1 - 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
unserialize Foo end unserialize Foo Called Foo::__wakeup
Output for 5.6.0 - 5.6.29, 7.0.0 - 7.0.14, 7.1.0
unserialize Foo Called Foo::__wakeup end unserialize Foo

preferences:
226.63 ms | 401 KiB | 288 Q