3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php declare(strict_types=1); function sum(int ...$ints): int { $a = 0; foreach ($ints as $int) { $a += $int; } return $a; } var_dump(sum(...[1, 2, 3])); var_dump(sum(...[1, 2, "three"]));
based on Eb5Vk
Output for 7.3.0alpha1
int(6) Fatal error: Uncaught TypeError: Argument 3 passed to sum() must be of the type int, string given, called in /in/FVlpE on line 13 and defined in /in/FVlpE:3 Stack trace: #0 /in/FVlpE(13): sum(1, 2, 'three') #1 {main} thrown in /in/FVlpE on line 3
Process exited with code 255.
Output for 7.0.30 - 7.2.6
int(6) Fatal error: Uncaught TypeError: Argument 3 passed to sum() must be of the type integer, string given, called in /in/FVlpE on line 13 and defined in /in/FVlpE:3 Stack trace: #0 /in/FVlpE(13): sum(1, 2, 'three') #1 {main} thrown in /in/FVlpE on line 3
Process exited with code 255.
Output for hhvm-3.22.0
Fatal error: Uncaught Error: Parameter $ints is variadic and has a type constraint (HH\int); variadic params with type constraints are not supported in non-Hack files in /in/FVlpE:-1 Stack trace: #0 {main}
Process exited with code 255.
Output for hhvm-3.18.5 - 3.21.3
Fatal error: Uncaught Error: Parameter $ints is variadic and has a type constraint (HH\int); variadic params with type constraints are not supported in non-Hack files in /in/FVlpE:3 Stack trace: #0 {main}
Process exited with code 255.
Output for 5.6.30
Warning: Unsupported declare 'strict_types' in /in/FVlpE on line 1 Parse error: syntax error, unexpected ':', expecting '{' in /in/FVlpE on line 3
Process exited with code 255.