3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Thing { private $foo; private $bar; private $qux; public function __construct($foo, $bar, $qux) { $this->foo = $foo; $this->bar = $bar; $this->qux = $qux; } } class Builder { private $foo; private $bar; public function withFoo($foo) { $this->foo = $foo; return $this; } public function withBar($bar) { $this->bar = $bar; return $this; } public function withQux($qux) { try { return new Thing($this->foo, $this->bar, $qux); } finally { $this->reset(); } } private function reset() { $this->foo = null; $this->bar = null; } } function test(Builder $builder) { return [ $builder->withFoo('a')->withBar('b')->withQux('c'), $builder->withFoo('d')->withQux('e'), $builder->withQux('f'), ]; } var_dump(test(new Builder()));
Output for git.master, git.master_jit, rfc.property-hooks
array(3) { [0]=> object(Thing)#2 (3) { ["foo":"Thing":private]=> string(1) "a" ["bar":"Thing":private]=> string(1) "b" ["qux":"Thing":private]=> string(1) "c" } [1]=> object(Thing)#3 (3) { ["foo":"Thing":private]=> string(1) "d" ["bar":"Thing":private]=> NULL ["qux":"Thing":private]=> string(1) "e" } [2]=> object(Thing)#4 (3) { ["foo":"Thing":private]=> NULL ["bar":"Thing":private]=> NULL ["qux":"Thing":private]=> string(1) "f" } }

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:
123.8 ms | 407 KiB | 5 Q