3v4l.org

run code in 300+ PHP versions simultaneously
<?php function test(int $x = null) { var_export($x); } test(1); test(null); test('x');
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.27, 8.2.0 - 8.2.17, 8.3.0 - 8.3.4
1NULL Fatal error: Uncaught TypeError: test(): Argument #1 ($x) must be of type ?int, string given, called in /in/5SGUh on line 7 and defined in /in/5SGUh:3 Stack trace: #0 /in/5SGUh(7): test('x') #1 {main} thrown in /in/5SGUh on line 3
Process exited with code 255.
Output for 7.3.0 - 7.3.33, 7.4.0 - 7.4.33
1NULL Fatal error: Uncaught TypeError: Argument 1 passed to test() must be of the type int or null, string given, called in /in/5SGUh on line 7 and defined in /in/5SGUh:3 Stack trace: #0 /in/5SGUh(7): test('x') #1 {main} thrown in /in/5SGUh on line 3
Process exited with code 255.
Output for 7.1.0 - 7.1.25, 7.2.0 - 7.2.33
1NULL Fatal error: Uncaught TypeError: Argument 1 passed to test() must be of the type integer or null, string given, called in /in/5SGUh on line 7 and defined in /in/5SGUh:3 Stack trace: #0 /in/5SGUh(7): test('x') #1 {main} thrown in /in/5SGUh on line 3
Process exited with code 255.
Output for 7.0.0 - 7.0.33
1NULL Fatal error: Uncaught TypeError: Argument 1 passed to test() must be of the type integer, string given, called in /in/5SGUh on line 7 and defined in /in/5SGUh:3 Stack trace: #0 /in/5SGUh(7): test('x') #1 {main} thrown in /in/5SGUh on line 3
Process exited with code 255.
Output for 5.5.0 - 5.5.38, 5.6.0 - 5.6.38
Catchable fatal error: Argument 1 passed to test() must be an instance of int, integer given, called in /in/5SGUh on line 5 and defined in /in/5SGUh on line 3
Process exited with code 255.

preferences:
210.82 ms | 401 KiB | 289 Q