3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php function addViaFor(array $numbers) { $sum = 0; foreach($numbers as $number) { $sum += $number; } return $sum; } function addViaWhile(array $numbers) { $sum = 0; while($numbers) { $sum += $numbers[0]; $numbers = array_shift($numbers); } return $sum; } function addViaRecursion(array $numbers) { // } echo addViaFor([3,5]) . "\r\n"; //echo addViaWhile([4,7]) . "\r\n"; //echo addViaRecursion([5,2]) . "\r\n";
based on PchOZ
Output for 5.4.0 - 7.2.0
8
Output for 5.1.0 - 5.3.29
Parse error: syntax error, unexpected '[', expecting ')' in /in/kC7LF on line 31
Process exited with code 255.
Output for 5.0.0 - 5.0.5
Parse error: parse error, unexpected T_ARRAY, expecting '&' or T_VARIABLE in /in/kC7LF on line 3
Process exited with code 255.
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_ARRAY, expecting ')' in /in/kC7LF on line 3
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1
Parse error: parse error, unexpected T_ARRAY, expecting ')' in /in/kC7LF on line 3
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error, expecting `')'' in /in/kC7LF on line 3
Process exited with code 255.