3v4l.org

run code in 300+ PHP versions simultaneously
<?php function sum(float ...$numbers) : float { $intsum = function ($sum, float ...$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
Fatal error: Uncaught TypeError: {closure}(): Argument #2 must be of type float, array given, called in /in/BPmgq on line 12 and defined in /in/BPmgq:5 Stack trace: #0 /in/BPmgq(12): {closure}(0, Array) #1 /in/BPmgq(15): sum(1.0, 2.0, 3.0, 4.0) #2 {main} thrown in /in/BPmgq on line 5
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:
46.45 ms | 401 KiB | 8 Q