3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class Foo { public function foo(int $arg) { return $arg; } } $foo = new Foo(); var_dump($foo->foo(''));
based on KoUXa
Output for 7.1.0 - 7.2.0
Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; Foo has a deprecated constructor in /in/kK5YN on line 3 Fatal error: Uncaught ArgumentCountError: Too few arguments to function Foo::foo(), 0 passed in /in/kK5YN on line 10 and exactly 1 expected in /in/kK5YN:5 Stack trace: #0 /in/kK5YN(10): Foo->foo() #1 {main} thrown in /in/kK5YN on line 5
Process exited with code 255.
Output for 7.0.0 - 7.0.20
Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; Foo has a deprecated constructor in /in/kK5YN on line 3 Fatal error: Uncaught TypeError: Argument 1 passed to Foo::foo() must be of the type integer, none given, called in /in/kK5YN on line 10 and defined in /in/kK5YN:5 Stack trace: #0 /in/kK5YN(10): Foo->foo() #1 {main} thrown in /in/kK5YN on line 5
Process exited with code 255.
Output for hhvm-3.11.1 - 3.17.3
Warning: foo() expects exactly 1 parameter, 0 given in /in/kK5YN on line 7 Fatal error: Uncaught TypeError: Argument 1 passed to Foo::foo() must be an instance of int, string given in /in/kK5YN:7 Stack trace: #0 /in/kK5YN(11): Foo->foo() #1 {main}
Process exited with code 255.
Output for hhvm-3.10.1
Warning: foo() expects exactly 1 parameter, 0 given in /in/kK5YN on line 7 Catchable fatal error: Argument 1 passed to Foo::foo() must be an instance of int, undefined variable given in /in/kK5YN on line 7
Process exited with code 255.
Output for 5.5.0 - 5.6.30
Catchable fatal error: Argument 1 passed to Foo::foo() must be an instance of int, none given, called in /in/kK5YN on line 10 and defined in /in/kK5YN on line 5
Process exited with code 255.