3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo { protected $bars = []; public function addBar(Bar $bar) { $this->bars[] = $bar; } } class Bar { protected $value; public function __construct($value) { $this->value = $value; } } $foo = new Foo; $foo->addBar(new Bar('baz')); $foo->addBar(new Bar(42)); $foo = serialize($foo); echo $foo, PHP_EOL; $foo = unserialize($foo); var_dump($foo);
Output for git.master, git.master_jit, rfc.property-hooks
O:3:"Foo":1:{s:7:"*bars";a:2:{i:0;O:3:"Bar":1:{s:8:"*value";s:3:"baz";}i:1;O:3:"Bar":1:{s:8:"*value";i:42;}}} object(Foo)#1 (1) { ["bars":protected]=> array(2) { [0]=> object(Bar)#3 (1) { ["value":protected]=> string(3) "baz" } [1]=> object(Bar)#2 (1) { ["value":protected]=> int(42) } } }

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:
54.39 ms | 401 KiB | 8 Q