3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php function foo(int $foo, int $bar) { echo $foo + $bar; } var_dump(foo(1, 1)); // affiche 2 var_dump(foo(1, '1')); // affiche 2 (conversion car mode coercitif) var_dump(foo('a', 1));
Output for 7.0.0 - 7.2.0
2NULL 2NULL Fatal error: Uncaught TypeError: Argument 1 passed to foo() must be of the type integer, string given, called in /in/T66P1 on line 10 and defined in /in/T66P1:3 Stack trace: #0 /in/T66P1(10): foo('a', 1) #1 {main} thrown in /in/T66P1 on line 3
Process exited with code 255.
Output for 5.3.20 - 5.6.28
Catchable fatal error: Argument 1 passed to foo() must be an instance of int, integer given, called in /in/T66P1 on line 8 and defined in /in/T66P1 on line 3
Process exited with code 255.