3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo { public function __construct(public string $bar, public string $baz) {} private function cloneModify(...$args) { $new = clone($this); foreach ($args as $k => $v) { $new->$k = $v; } return $new; } public function withBar(string $bar) { return $this->cloneModify(bar: $bar); } } $f = new Foo('a', 'b'); $f2 = $f->withBar('beep'); var_dump($f2);
Output for git.master, git.master_jit, rfc.property-hooks
object(Foo)#2 (2) { ["bar"]=> string(4) "beep" ["baz"]=> string(1) "b" }

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.88 ms | 1158 KiB | 4 Q