3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Point { public readonly string $name; public function __construct( public readonly int $x, public readonly int $y, ) {} public function setName(string $name): static { $this->name ??= $name; return $this; } } $p = new Point(3, 4); $p->setName('Larry'); var_dump($p); $p2 = new class extends Point { public function __construct() { $this->x = 3; $this->y = 4; $this->name = 'Larry'; } }; var_dump($p2);
Output for git.master_jit, git.master
object(Point)#1 (3) { ["name"]=> string(5) "Larry" ["x"]=> int(3) ["y"]=> int(4) } object(Point@anonymous)#2 (3) { ["name"]=> string(5) "Larry" ["x"]=> int(3) ["y"]=> int(4) }

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:
60.96 ms | 1063 KiB | 4 Q