3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Test { public function callback() {} } class Test2 { public function set(callable $callback) {} } $callback = 'Test::callback'; var_dump(is_callable($callback)); $a = new Test2(); $a->set($callback); ?>
Output for 8.0.0 - 8.0.22, 8.1.0 - 8.1.9
bool(false) Fatal error: Uncaught TypeError: Test2::set(): Argument #1 ($callback) must be of type callable, string given, called in /in/ilbYM on line 14 and defined in /in/ilbYM:6 Stack trace: #0 /in/ilbYM(14): Test2->set('Test::callback') #1 {main} thrown in /in/ilbYM on line 6
Process exited with code 255.
Output for 7.2.0 - 7.2.34, 7.3.0 - 7.3.31, 7.3.33, 7.4.0 - 7.4.25, 7.4.27 - 7.4.30
bool(true) Deprecated: Non-static method Test::callback() should not be called statically in /in/ilbYM on line 6
Output for 7.3.32, 7.4.26
bool(true)

preferences:
26.5 ms | 411 KiB | 5 Q