3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Something { public function action() { return 'Hello, World!'; } } $callable1 = [Something::class, 'action']; $callable1 = ['SomethingContainerName', 'action']; $callable2 = 'Something::action'; var_dump(is_callable($callable1)); var_dump(is_callable($callable2)); function test(callable $callable) { return is_callable($callable); } var_dump(test($callable1)); var_dump(test($callable2));
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
bool(false) bool(false) Fatal error: Uncaught TypeError: test(): Argument #1 ($callable) must be of type callable, array given, called in /in/7HC7m on line 22 and defined in /in/7HC7m:18 Stack trace: #0 /in/7HC7m(22): test(Array) #1 {main} thrown in /in/7HC7m on line 18
Process exited with code 255.
Output for 7.0.0 - 7.0.20, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33
bool(false) bool(true) Fatal error: Uncaught TypeError: Argument 1 passed to test() must be callable, array given, called in /in/7HC7m on line 22 and defined in /in/7HC7m:18 Stack trace: #0 /in/7HC7m(22): test(Array) #1 {main} thrown in /in/7HC7m on line 18
Process exited with code 255.
Output for 5.5.24 - 5.5.35, 5.6.8 - 5.6.28
bool(false) bool(true) Catchable fatal error: Argument 1 passed to test() must be callable, array given, called in /in/7HC7m on line 22 and defined in /in/7HC7m on line 18
Process exited with code 255.
Output for 5.4.1 - 5.4.45
Parse error: syntax error, unexpected 'class' (T_CLASS), expecting identifier (T_STRING) or variable (T_VARIABLE) or '{' or '$' in /in/7HC7m on line 11
Process exited with code 255.

preferences:
210.9 ms | 401 KiB | 272 Q