3v4l.org

run code in 300+ PHP versions simultaneously
<?php function sum(float ...$numbers) : float { $intsum = function ($sum, array $numbers) { $number = array_shift($numbers); $sum += $number; return $intsum($numbers, $sum); }; return $intsum(0, $numbers); } echo sum(1, 2, 3, 4); echo PHP_EOL; echo sum(1.5, 2, 3, 4); echo PHP_EOL; try { sum('a', 'b', 'c'); } catch (Error $e) { echo $e->getMessage(); }
Output for git.master, git.master_jit, rfc.property-hooks
Warning: Undefined variable $intsum in /in/pdmNm on line 9 Fatal error: Uncaught Error: Value of type null is not callable in /in/pdmNm:9 Stack trace: #0 /in/pdmNm(12): {closure}(1.0, Array) #1 /in/pdmNm(15): sum(1.0, 2.0, 3.0, 4.0) #2 {main} thrown in /in/pdmNm on line 9
Process exited with code 255.

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:
49.36 ms | 401 KiB | 8 Q