3v4l.org

run code in 300+ PHP versions simultaneously
<?php class TestClass { public function doIt() { echo 'done'; } } function is_instance_callable(array $definition) { return isset($definition[0], $definition[1]) && in_array($definition[1], get_class_methods($definition[0]) ?? [], true); } $callable = ['ljkkjljlkj', 'doIt']; var_dump(is_instance_callable($callable));
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.33, 8.2.0 - 8.2.29, 8.3.0 - 8.3.25, 8.4.1 - 8.4.12
Fatal error: Uncaught TypeError: get_class_methods(): Argument #1 ($object_or_class) must be an object or a valid class name, string given in /in/VLL4i:13 Stack trace: #0 /in/VLL4i(13): get_class_methods('ljkkjljlkj') #1 /in/VLL4i(18): is_instance_callable(Array) #2 {main} thrown in /in/VLL4i on line 13
Process exited with code 255.
Output for 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33
bool(false)

preferences:
87.1 ms | 407 KiB | 5 Q