3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Example { public function foo(int $f = null) { } } $e = new Example; // $e->foo(null); //$e->foo(9); $e->foo('string');
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
Fatal error: Uncaught TypeError: Example::foo(): Argument #1 ($f) must be of type ?int, string given, called in /in/vUPpT on line 13 and defined in /in/vUPpT:4 Stack trace: #0 /in/vUPpT(13): Example->foo('string') #1 {main} thrown in /in/vUPpT on line 4
Process exited with code 255.
Output for 7.3.24 - 7.3.33, 7.4.12 - 7.4.33
Fatal error: Uncaught TypeError: Argument 1 passed to Example::foo() must be of the type int or null, string given, called in /in/vUPpT on line 13 and defined in /in/vUPpT:4 Stack trace: #0 /in/vUPpT(13): Example->foo('string') #1 {main} thrown in /in/vUPpT on line 4
Process exited with code 255.
Output for 7.1.7
Fatal error: Uncaught TypeError: Argument 1 passed to Example::foo() must be of the type integer or null, string given, called in /in/vUPpT on line 13 and defined in /in/vUPpT:4 Stack trace: #0 /in/vUPpT(13): Example->foo('string') #1 {main} thrown in /in/vUPpT on line 4
Process exited with code 255.

preferences:
120.61 ms | 401 KiB | 115 Q