3v4l.org

run code in 300+ PHP versions simultaneously
<?php class ObjectWithReferences { protected $var1; protected $var2; protected $var3; public function __construct() { $this->var1 = new StdClass(); $this->var2 = null; $this->var3 = $this->var1; } } class WrapperObject implements Serializable { static $tempstorage; protected $obj; public function setObject($obj) { $this->obj = $obj; } public function getObject() { if (is_string($this->obj)) { $this->obj = unserialize($this->obj); } return $this->obj; } public function save() { $archive = (object) [ 'object' => is_string($this->obj) ? $this->obj : serialize($this->obj), ]; static::$tempstorage = json_encode($archive); var_dump("Serialized:", static::$tempstorage); } public function load() { $archive = json_decode(static::$tempstorage); $this->obj = $archive->object; } public function serialize() { $this->save(false); return "wrapper!"; // Doesn't actually matter here. } public function unserialize($serialized) { $this->load(); } } $owr = new ObjectWithReferences(); $wrapper = new WrapperObject(); $wrapper->setObject($owr); $wrapper->save(); $wrapper->load(); var_dump($wrapper->getObject()); $serialized = serialize($wrapper); $wrapper = unserialize($serialized); var_dump($wrapper->getObject());
Output for git.master, git.master_jit
Deprecated: WrapperObject 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/EcWl3 on line 15 string(11) "Serialized:" string(152) "{"object":"O:20:\"ObjectWithReferences\":3:{s:7:\"\u0000*\u0000var1\";O:8:\"stdClass\":0:{}s:7:\"\u0000*\u0000var2\";N;s:7:\"\u0000*\u0000var3\";r:2;}"}" object(ObjectWithReferences)#4 (3) { ["var1":protected]=> object(stdClass)#5 (0) { } ["var2":protected]=> NULL ["var3":protected]=> object(stdClass)#5 (0) { } } string(11) "Serialized:" string(152) "{"object":"O:20:\"ObjectWithReferences\":3:{s:7:\"\u0000*\u0000var1\";O:8:\"stdClass\":0:{}s:7:\"\u0000*\u0000var2\";N;s:7:\"\u0000*\u0000var3\";r:3;}"}" Notice: unserialize(): Error at offset 98 of 99 bytes in /in/EcWl3 on line 27 bool(false)
Output for rfc.property-hooks
Deprecated: WrapperObject 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/EcWl3 on line 15 string(11) "Serialized:" string(152) "{"object":"O:20:\"ObjectWithReferences\":3:{s:7:\"\u0000*\u0000var1\";O:8:\"stdClass\":0:{}s:7:\"\u0000*\u0000var2\";N;s:7:\"\u0000*\u0000var3\";r:2;}"}" object(ObjectWithReferences)#4 (3) { ["var1":protected]=> object(stdClass)#5 (0) { } ["var2":protected]=> NULL ["var3":protected]=> object(stdClass)#5 (0) { } } string(11) "Serialized:" string(152) "{"object":"O:20:\"ObjectWithReferences\":3:{s:7:\"\u0000*\u0000var1\";O:8:\"stdClass\":0:{}s:7:\"\u0000*\u0000var2\";N;s:7:\"\u0000*\u0000var3\";r:3;}"}" Warning: unserialize(): Error at offset 98 of 99 bytes in /in/EcWl3 on line 27 bool(false)

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