3v4l.org

run code in 300+ PHP versions simultaneously
<?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'));
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
int(3) Fatal error: Uncaught TypeError: add(): Argument #2 ($y) must be of type int, 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 7.3.0 - 7.3.33, 7.4.0 - 7.4.33
int(3) Fatal error: Uncaught TypeError: Argument 2 passed to add() must be of the type int, 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 7.0.0 - 7.0.20, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33
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.5.38, 5.6.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.

preferences:
184.43 ms | 402 KiB | 268 Q