3v4l.org

run code in 300+ PHP versions simultaneously
<?php function sum() { $list = array(); $prepare = function($value) use(&$prepare, &$list) { if (is_array($value)) { array_walk($value, $prepare, $list); } $list[] = $value; }; $args = func_get_args(); array_walk($args, $prepare, $list); var_dump($list); return addition(0, $list); } function addition($sum, array &$list) { return empty($list) ? $sum : addition($sum + array_pop($list), $list); } $vars = range(1, 10); echo sum(array($vars), array(1));
Output for git.master, git.master_jit, rfc.property-hooks
array(14) { [0]=> int(1) [1]=> int(2) [2]=> int(3) [3]=> int(4) [4]=> int(5) [5]=> int(6) [6]=> int(7) [7]=> int(8) [8]=> int(9) [9]=> int(10) [10]=> array(10) { [0]=> int(1) [1]=> int(2) [2]=> int(3) [3]=> int(4) [4]=> int(5) [5]=> int(6) [6]=> int(7) [7]=> int(8) [8]=> int(9) [9]=> int(10) } [11]=> array(1) { [0]=> array(10) { [0]=> int(1) [1]=> int(2) [2]=> int(3) [3]=> int(4) [4]=> int(5) [5]=> int(6) [6]=> int(7) [7]=> int(8) [8]=> int(9) [9]=> int(10) } } [12]=> int(1) [13]=> array(1) { [0]=> int(1) } } Fatal error: Uncaught TypeError: Unsupported operand types: int + array in /in/9rHr2:21 Stack trace: #0 /in/9rHr2(17): addition(0, Array) #1 /in/9rHr2(25): sum(Array, Array) #2 {main} thrown in /in/9rHr2 on line 21
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:
65.7 ms | 402 KiB | 8 Q