3v4l.org

run code in 300+ PHP versions simultaneously
<?php declare(strict_types=1); $foo = function (string $bar = null ) { var_dump($bar); }; $foo(); $foo(null); $foo('100'); $foo(100); $foo([100]);
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
NULL NULL string(3) "100" Fatal error: Uncaught TypeError: {closure}(): Argument #1 ($bar) must be of type ?string, int given, called in /in/OkYTH on line 13 and defined in /in/OkYTH:6 Stack trace: #0 /in/OkYTH(13): {closure}(100) #1 {main} thrown in /in/OkYTH on line 6
Process exited with code 255.
Output for 7.3.16 - 7.3.33, 7.4.0 - 7.4.33
NULL NULL string(3) "100" Fatal error: Uncaught TypeError: Argument 1 passed to {closure}() must be of the type string or null, int given, called in /in/OkYTH on line 13 and defined in /in/OkYTH:6 Stack trace: #0 /in/OkYTH(13): {closure}(100) #1 {main} thrown in /in/OkYTH on line 6
Process exited with code 255.
Output for 7.1.0 - 7.1.20, 7.2.0 - 7.2.33
NULL NULL string(3) "100" Fatal error: Uncaught TypeError: Argument 1 passed to {closure}() must be of the type string or null, integer given, called in /in/OkYTH on line 13 and defined in /in/OkYTH:6 Stack trace: #0 /in/OkYTH(13): {closure}(100) #1 {main} thrown in /in/OkYTH on line 6
Process exited with code 255.
Output for 7.0.0 - 7.0.20
NULL NULL string(3) "100" Fatal error: Uncaught TypeError: Argument 1 passed to {closure}() must be of the type string, integer given, called in /in/OkYTH on line 13 and defined in /in/OkYTH:6 Stack trace: #0 /in/OkYTH(13): {closure}(100) #1 {main} thrown in /in/OkYTH on line 6
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/OkYTH on line 3 NULL NULL Catchable fatal error: Argument 1 passed to {closure}() must be an instance of string, string given, called in /in/OkYTH on line 12 and defined in /in/OkYTH on line 6
Process exited with code 255.

preferences:
152.25 ms | 402 KiB | 179 Q