3v4l.org

run code in 300+ PHP versions simultaneously
<?php declare(strict_types=1); function square(int $a): int { return $a * $a; } print_r(square(4)); print_r(square(3.4));
Output for 8.0.0 - 8.0.20, 8.1.0 - 8.1.7
16 Fatal error: Uncaught TypeError: square(): Argument #1 ($a) must be of type int, float given, called in /in/5TUje on line 8 and defined in /in/5TUje:3 Stack trace: #0 /in/5TUje(8): square(3.4) #1 {main} thrown in /in/5TUje on line 3
Process exited with code 255.
Output for 7.3.0 - 7.3.33, 7.4.0 - 7.4.30
16 Fatal error: Uncaught TypeError: Argument 1 passed to square() must be of the type int, float given, called in /in/5TUje on line 8 and defined in /in/5TUje:3 Stack trace: #0 /in/5TUje(8): square(3.4) #1 {main} thrown in /in/5TUje on line 3
Process exited with code 255.
Output for 7.1.25 - 7.1.32, 7.2.0 - 7.2.33
16 Fatal error: Uncaught TypeError: Argument 1 passed to square() must be of the type integer, float given, called in /in/5TUje on line 8 and defined in /in/5TUje:3 Stack trace: #0 /in/5TUje(8): square(3.4) #1 {main} thrown in /in/5TUje on line 3
Process exited with code 255.

preferences:
48.85 ms | 412 KiB | 5 Q