3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?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));
based on JQks2
Output for 7.0.0 - 7.2.0
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 5.5.24 - 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.
Output for 5.3.18 - 5.3.29
Parse error: syntax error, unexpected '[' in /in/hubg8 on line 11
Process exited with code 255.