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);

preferences:
75.88 ms | 402 KiB | 5 Q