3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Something { public function action() { return 'Hello, World!'; } } $callable1 = [Something::class, 'action']; $callable2 = 'Something::action'; $callable3 = ['SomethingContainerName', 'action']; var_dump(is_callable($callable1)); var_dump(is_callable($callable2)); var_dump(is_callable($callable3)); function test(callable $callable) { return is_callable($callable); } var_dump(test($callable1)); var_dump(test($callable2)); var_dump(test($callable3));
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.29, 8.2.0 - 8.2.21, 8.3.0 - 8.3.9
bool(false) bool(false) bool(false) Fatal error: Uncaught TypeError: test(): Argument #1 ($callable) must be of type callable, array given, called in /in/hubg8 on line 23 and defined in /in/hubg8:19 Stack trace: #0 /in/hubg8(23): test(Array) #1 {main} thrown in /in/hubg8 on line 19
Process exited with code 255.
Output for 7.0.0 - 7.0.20, 7.1.0 - 7.1.25, 7.2.0 - 7.2.33, 7.3.0 - 7.3.31, 7.4.0 - 7.4.33
bool(true) bool(true) bool(false) Deprecated: Non-static method Something::action() should not be called statically in /in/hubg8 on line 19 bool(true) Deprecated: Non-static method Something::action() should not be called statically in /in/hubg8 on line 19 bool(true) Fatal error: Uncaught TypeError: Argument 1 passed to test() must be callable, array given, called in /in/hubg8 on line 25 and defined in /in/hubg8:19 Stack trace: #0 /in/hubg8(25): test(Array) #1 {main} thrown in /in/hubg8 on line 19
Process exited with code 255.
Output for 7.3.32 - 7.3.33
bool(true) bool(true) bool(false) bool(true) bool(true) Fatal error: Uncaught TypeError: Argument 1 passed to test() must be callable, array given, called in /in/hubg8 on line 25 and defined in /in/hubg8:19 Stack trace: #0 /in/hubg8(25): test(Array) #1 {main} thrown in /in/hubg8 on line 19
Process exited with code 255.
Output for 5.5.24 - 5.5.35, 5.6.8 - 5.6.28
bool(true) bool(true) bool(false) Strict Standards: Non-static method Something::action() should not be called statically in /in/hubg8 on line 19 bool(true) Strict Standards: Non-static method Something::action() should not be called statically in /in/hubg8 on line 19 bool(true) Catchable fatal error: Argument 1 passed to test() must be callable, array given, called in /in/hubg8 on line 25 and defined in /in/hubg8 on line 19
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/hubg8 on line 11
Process exited with code 255.

preferences:
194.46 ms | 402 KiB | 249 Q