3v4l.org

run code in 300+ PHP versions simultaneously
<?php function sum($x) { return new class ($x) { function __construct(private int $x = 0) {} function __invoke($num): static { return new static($num + $this->x); } function __toString(): string { return (string)$this->x; } }; } echo sum(1000)(400)(80)(8)(200)(20)(2);
Output for 8.1.0 - 8.1.34, 8.2.0 - 8.2.30, 8.3.0 - 8.3.30, 8.4.1 - 8.4.18, 8.5.0 - 8.5.3
1710

preferences:
66.98 ms | 971 KiB | 4 Q