3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Widget implements Serializable { public $references = array(); public $config; public function serialize() { $vars = get_object_vars($this); $vars['config'] = serialize($vars['config']); $serialized = serialize($vars); return $serialized; } public function unserialize($serialized) { $array = unserialize($serialized); $array['config'] = unserialize($array['config']); foreach($array as $k => $v) { $this->$k = $v; } } } class Placeholder { public $id; public function __construct($id) { $this->id = $id; } } $collection = array(); $placeholder1 = new Placeholder(1); $placeholder2 = new Placeholder(2); $widget1 = new Widget; $widget1->config = array('id_section' => 9); $widget1->references[] = $placeholder1; $widget2 = new Widget; $widget2->config = array('id_section' => 9); $widget2->references[] = $placeholder2; $widget3 = new Widget; $widget3->config = array('id_section' => 9); $widget3->references[] = $placeholder1; $widget4 = new Widget; $widget4->config = array('id_section' => 9); $widget4->references[] = $placeholder1; $collection[] = $widget1; $collection[] = $widget2; $collection[] = $widget3; // reference to placeholder will be missing here $collection[] = $widget4; // reference to placeholder will be missing here print_r(unserialize(serialize($collection)));
Output for git.master, git.master_jit
Deprecated: Widget 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/FjJmf on line 3 Notice: unserialize(): Error at offset 36 of 87 bytes in /in/FjJmf on line 21 Warning: Trying to access array offset on value of type bool in /in/FjJmf on line 23 Deprecated: unserialize(): Passing null to parameter #1 ($data) of type string is deprecated in /in/FjJmf on line 23 Deprecated: Automatic conversion of false to array is deprecated in /in/FjJmf on line 23 Notice: unserialize(): Error at offset 36 of 87 bytes in /in/FjJmf on line 21 Warning: Trying to access array offset on value of type bool in /in/FjJmf on line 23 Deprecated: unserialize(): Passing null to parameter #1 ($data) of type string is deprecated in /in/FjJmf on line 23 Deprecated: Automatic conversion of false to array is deprecated in /in/FjJmf on line 23 Array ( [0] => Widget Object ( [references] => Array ( [0] => Placeholder Object ( [id] => 1 ) ) [config] => Array ( [id_section] => 9 ) ) [1] => Widget Object ( [references] => Array ( [0] => Placeholder Object ( [id] => 2 ) ) [config] => Array ( [id_section] => 9 ) ) [2] => Widget Object ( [references] => Array ( ) [config] => ) [3] => Widget Object ( [references] => Array ( ) [config] => ) )
Output for rfc.property-hooks
Deprecated: Widget 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/FjJmf on line 3 Warning: unserialize(): Error at offset 36 of 87 bytes in /in/FjJmf on line 21 Warning: Trying to access array offset on false in /in/FjJmf on line 23 Deprecated: unserialize(): Passing null to parameter #1 ($data) of type string is deprecated in /in/FjJmf on line 23 Deprecated: Automatic conversion of false to array is deprecated in /in/FjJmf on line 23 Warning: unserialize(): Error at offset 36 of 87 bytes in /in/FjJmf on line 21 Warning: Trying to access array offset on false in /in/FjJmf on line 23 Deprecated: unserialize(): Passing null to parameter #1 ($data) of type string is deprecated in /in/FjJmf on line 23 Deprecated: Automatic conversion of false to array is deprecated in /in/FjJmf on line 23 Array ( [0] => Widget Object ( [references] => Array ( [0] => Placeholder Object ( [id] => 1 ) ) [config] => Array ( [id_section] => 9 ) ) [1] => Widget Object ( [references] => Array ( [0] => Placeholder Object ( [id] => 2 ) ) [config] => Array ( [id_section] => 9 ) ) [2] => Widget Object ( [references] => Array ( ) [config] => ) [3] => Widget Object ( [references] => Array ( ) [config] => ) )

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:
39.3 ms | 405 KiB | 8 Q