3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Role { } class Foo implements Serializable { private $var1; public function __construct() { $this->var1 = array(new Role()); } public function serialize() { return serialize(array($this->var1)); } public function unserialize($serialized) { list($this->var1) = unserialize($serialized); } } class Bar extends Foo { private $var2; public function __construct() { parent::__construct(); $this->var2 = new \stdClass(); } public function serialize() { return serialize(array($this->var2, parent::serialize())); } public function unserialize($serialized) { list($this->var2, $parentStr) = unserialize($serialized); parent::unserialize($parentStr); } } $foo = new Bar; var_dump(unserialize(serialize($foo)));
Output for git.master, git.master_jit, rfc.property-hooks
Deprecated: Foo 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/64GT7 on line 7 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/64GT7 on line 24 object(Bar)#4 (2) { ["var1":"Foo":private]=> array(1) { [0]=> object(Role)#6 (0) { } } ["var2":"Bar":private]=> object(stdClass)#5 (0) { } }

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
45.52 ms | 402 KiB | 8 Q