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);

This is an error 500

Value for `_results` contains invalid data `array`


preferences:
172.64 ms | 1676 KiB | 11 Q