3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo { private $count; public function __construct() { $this->count = 1; } public function addCount() { $this->count++; } } class Bar { private $foo; private $array; public function __construct() { $this->foo = new Foo; $this->array = array(1, 2, 3); } public function getFoo() { return $this->foo; } public function getArray() { return $this->array; } } $bar = new Bar; $foo = $bar->getFoo(); $array = $bar->getArray(); var_dump($bar->getFoo()); print '<br>'; var_dump($foo); print '<br>'; var_dump($bar->getArray()); print '<br>'; var_dump($array); print '<br>'; $foo->addCount(); $array[] = 4; var_dump($bar->getFoo()); print '<br>'; var_dump($foo); print '<br>'; var_dump($bar->getArray()); print '<br>'; var_dump($array); print '<br>';
Output for git.master, git.master_jit, rfc.property-hooks
object(Foo)#2 (1) { ["count":"Foo":private]=> int(1) } <br>object(Foo)#2 (1) { ["count":"Foo":private]=> int(1) } <br>array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3) } <br>array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3) } <br>object(Foo)#2 (1) { ["count":"Foo":private]=> int(2) } <br>object(Foo)#2 (1) { ["count":"Foo":private]=> int(2) } <br>array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3) } <br>array(4) { [0]=> int(1) [1]=> int(2) [2]=> int(3) [3]=> int(4) } <br>

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.82 ms | 402 KiB | 8 Q