3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class Example { public function foo(int $f = null) { } } $e = new Example; $e->foo(null); $e->foo(9); $e->foo('string');
Output for 7.3.0 - 7.3.1
Fatal error: Uncaught TypeError: Argument 1 passed to Example::foo() must be of the type int or null, string given, called in /in/2aPpc on line 13 and defined in /in/2aPpc:4 Stack trace: #0 /in/2aPpc(13): Example->foo('string') #1 {main} thrown in /in/2aPpc on line 4
Process exited with code 255.
Output for 7.1.0 - 7.2.13
Fatal error: Uncaught TypeError: Argument 1 passed to Example::foo() must be of the type integer or null, string given, called in /in/2aPpc on line 13 and defined in /in/2aPpc:4 Stack trace: #0 /in/2aPpc(13): Example->foo('string') #1 {main} thrown in /in/2aPpc on line 4
Process exited with code 255.
Output for 7.0.0 - 7.0.31
Fatal error: Uncaught TypeError: Argument 1 passed to Example::foo() must be of the type integer, string given, called in /in/2aPpc on line 13 and defined in /in/2aPpc:4 Stack trace: #0 /in/2aPpc(13): Example->foo('string') #1 {main} thrown in /in/2aPpc on line 4
Process exited with code 255.
Output for hhvm-3.22.0
Fatal error: Uncaught TypeError: Argument 1 passed to Example::foo() must be an instance of int, string given in /in/2aPpc:-1 Stack trace: #0 /in/2aPpc(-1): Example->foo() #1 {main}
Process exited with code 255.
Output for hhvm-3.15.4 - 3.21.3
Fatal error: Uncaught TypeError: Argument 1 passed to Example::foo() must be an instance of int, string given in /in/2aPpc:7 Stack trace: #0 /in/2aPpc(13): Example->foo() #1 {main}
Process exited with code 255.
Output for 5.6.30
Catchable fatal error: Argument 1 passed to Example::foo() must be an instance of int, integer given, called in /in/2aPpc on line 12 and defined in /in/2aPpc on line 4
Process exited with code 255.