3v4l.org

run code in 300+ PHP versions simultaneously
<?php declare(strict_types=1); function setAge(int $age) { var_dump($age); } // First test is clearly wrong // setAge("totally not an int"); <-- Fatal error expected int found string // Try passing something like this setAge("30+1"); // What about this? setAge("30"); // Finally a real int :) setAge(30); // U jelly? setAge(.1);
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.19, 8.3.0 - 8.3.7
Fatal error: Uncaught TypeError: setAge(): Argument #1 ($age) must be of type int, string given, called in /in/b16nd on line 12 and defined in /in/b16nd:4 Stack trace: #0 /in/b16nd(12): setAge('30+1') #1 {main} thrown in /in/b16nd on line 4
Process exited with code 255.
Output for 7.3.16 - 7.3.33, 7.4.0 - 7.4.33
Fatal error: Uncaught TypeError: Argument 1 passed to setAge() must be of the type int, string given, called in /in/b16nd on line 12 and defined in /in/b16nd:4 Stack trace: #0 /in/b16nd(12): setAge('30+1') #1 {main} thrown in /in/b16nd on line 4
Process exited with code 255.
Output for 7.0.0 - 7.0.20, 7.1.0 - 7.1.20, 7.2.0 - 7.2.33
Fatal error: Uncaught TypeError: Argument 1 passed to setAge() must be of the type integer, string given, called in /in/b16nd on line 12 and defined in /in/b16nd:4 Stack trace: #0 /in/b16nd(12): setAge('30+1') #1 {main} thrown in /in/b16nd on line 4
Process exited with code 255.
Output for 5.5.24 - 5.5.35, 5.6.8 - 5.6.28
Warning: Unsupported declare 'strict_types' in /in/b16nd on line 2 Catchable fatal error: Argument 1 passed to setAge() must be an instance of int, string given, called in /in/b16nd on line 12 and defined in /in/b16nd on line 4
Process exited with code 255.

preferences:
146.91 ms | 402 KiB | 185 Q