3v4l.org

run code in 300+ PHP versions simultaneously
<?php namespace Test; class Foo { public function bar(\callable $a) { $a(); } public function hello() { echo 'World' . PHP_EOL; } public function test($a) { echo 'Hello' . PHP_EOL; } } $foo = new Foo(); echo is_callable(array($foo, 'hello')); $foo->bar(array($foo, 'hello'));
Output for 8.1.23 - 8.1.28, 8.2.10 - 8.2.18, 8.3.0 - 8.3.6
1 Fatal error: Uncaught TypeError: Test\Foo::bar(): Argument #1 ($a) must be of type callable, array given, called in /in/DGmOG on line 20 and defined in /in/DGmOG:6 Stack trace: #0 /in/DGmOG(20): Test\Foo->bar(Array) #1 {main} thrown in /in/DGmOG on line 6
Process exited with code 255.
Output for 5.4.0 - 5.4.23
Parse error: syntax error, unexpected 'callable' (T_CALLABLE), expecting identifier (T_STRING) in /in/DGmOG on line 6
Process exited with code 255.
Output for 5.3.0 - 5.3.28
1 Catchable fatal error: Argument 1 passed to Test\Foo::bar() must be an instance of callable, array given, called in /in/DGmOG on line 20 and defined in /in/DGmOG on line 6
Process exited with code 255.

preferences:
88.42 ms | 402 KiB | 80 Q