3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php declare(strict_types=1); function add(int $x, int $y): int { return $x + $y; } var_dump(add(1, 2)); var_dump(add(1, '2'));
based on Gq4NK
Output for 7.0.0 - 7.2.0
int(3) Fatal error: Uncaught TypeError: Argument 2 passed to add() must be of the type integer, string given, called in /in/H0TBk on line 7 and defined in /in/H0TBk:3 Stack trace: #0 /in/H0TBk(7): add(1, '2') #1 {main} thrown in /in/H0TBk on line 3
Process exited with code 255.
Output for 5.5.0 - 5.6.28
Warning: Unsupported declare 'strict_types' in /in/H0TBk on line 2 Parse error: syntax error, unexpected ':', expecting '{' in /in/H0TBk on line 3
Process exited with code 255.