3v4l.org

run code in 300+ PHP versions simultaneously
<?php interface Summable { public function getNumericValue(): int; } class One implements Summable { public function getNumericValue(): int { return 1; } } class Two implements Summable { public function getNumericValue(): int { return 2; } } function sumNumbers(Summable ...$numbers): int { return array_reduce($numbers, fn($sum, Summable $number) => $sum += $number->getNumericValue()); } $numbers = [new One, new Two, new Two]; echo sumNumbers(...$numbers);
Output for git.master, git.master_jit, rfc.property-hooks
5

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:
51.95 ms | 405 KiB | 5 Q