3v4l.org

run code in 300+ PHP versions simultaneously
<?php class SerializableClass implements Serializable { public $sharedProp; public function __construct($prop) { $this->sharedProp = $prop; } public function __set($key, $value) { $this->$key = $value; } public function serialize() { return serialize(get_object_vars($this)); } public function unserialize($data) { $ar = unserialize($data); if ($ar === false) { return; } foreach ($ar as $k => $v) { $this->__set($k, $v); } } } spl_autoload_register(function($class) { $testPropertyObj = new stdClass(); $testPropertyObj->name = 'test'; $array = [ 'obj1' => new SerializableClass($testPropertyObj), 'obj2' => new SerializableClass($testPropertyObj), ]; var_dump(unserialize(serialize($array))); class X {} }); unserialize('O:1:"X":0:{}');
Output for git.master, git.master_jit, rfc.property-hooks
Deprecated: SerializableClass 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/cZqVf on line 3 array(2) { ["obj1"]=> object(SerializableClass)#5 (1) { ["sharedProp"]=> object(stdClass)#6 (1) { ["name"]=> string(4) "test" } } ["obj2"]=> object(SerializableClass)#7 (1) { ["sharedProp"]=> object(stdClass)#8 (1) { ["name"]=> string(4) "test" } } }

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:
56.51 ms | 402 KiB | 8 Q