3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Something { public function action() { return 'Hello, World!'; } } $callable1 = [Something::class, 'action']; $callable2 = ['SomethingContainerName', 'action']; $callable3 = 'Something::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.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
bool(false) bool(false) bool(false) Fatal error: Uncaught TypeError: test(): Argument #1 ($callable) must be of type callable, array given, called in /in/JQks2 on line 23 and defined in /in/JQks2:19 Stack trace: #0 /in/JQks2(23): test(Array) #1 {main} thrown in /in/JQks2 on line 19
Process exited with code 255.
Output for 7.0.0 - 7.0.33, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.31, 7.4.0 - 7.4.33
bool(true) bool(false) bool(true) Deprecated: Non-static method Something::action() should not be called statically in /in/JQks2 on line 19 bool(true) Fatal error: Uncaught TypeError: Argument 1 passed to test() must be callable, array given, called in /in/JQks2 on line 24 and defined in /in/JQks2:19 Stack trace: #0 /in/JQks2(24): test(Array) #1 {main} thrown in /in/JQks2 on line 19
Process exited with code 255.
Output for 7.3.32 - 7.3.33
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/JQks2 on line 24 and defined in /in/JQks2:19 Stack trace: #0 /in/JQks2(24): test(Array) #1 {main} thrown in /in/JQks2 on line 19
Process exited with code 255.
Output for 5.5.0 - 5.5.38, 5.6.0 - 5.6.40
bool(true) bool(false) bool(true) Strict Standards: Non-static method Something::action() should not be called statically in /in/JQks2 on line 19 bool(true) Catchable fatal error: Argument 1 passed to test() must be callable, array given, called in /in/JQks2 on line 24 and defined in /in/JQks2 on line 19
Process exited with code 255.
Output for 5.4.0 - 5.4.45
Parse error: syntax error, unexpected 'class' (T_CLASS), expecting identifier (T_STRING) or variable (T_VARIABLE) or '{' or '$' in /in/JQks2 on line 11
Process exited with code 255.

preferences:
284.52 ms | 401 KiB | 376 Q