3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo { public function bar() { } public static function barS() { } } function x() { } print_r(Closure::fromCallable([new Foo(), 'bar'])); print_r(Closure::fromCallable([Foo::class, 'barS'])); print_r(x(...));
Output for 8.2.22 - 8.2.29, 8.3.5 - 8.3.25, 8.4.1 - 8.4.12
Closure Object ( [function] => Foo::bar [this] => Foo Object ( ) ) Closure Object ( [function] => Foo::barS ) Closure Object ( [function] => x )
Output for 8.1.0 - 8.1.33
Closure Object ( [this] => Foo Object ( ) ) Closure Object ( ) Closure Object ( )
Output for 8.0.1 - 8.0.21
Parse error: syntax error, unexpected token ")" in /in/s8HvF on line 16
Process exited with code 255.
Output for 7.4.0 - 7.4.30
Parse error: syntax error, unexpected ')' in /in/s8HvF on line 16
Process exited with code 255.

preferences:
62.51 ms | 409 KiB | 5 Q