3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class A { private function foo() { return 'bar'; } public function test() { $b = new B(); $b->call(function() { $this->foo(); }); } } class B { private function foo() { return 'buzz'; } public function call (callable $fnc) { echo $fnc; } } $a = new A(); $a->test();
based on F6UV0
Output for 7.1.0 - 7.2.0
Recoverable fatal error: Object of class Closure could not be converted to string in /in/buIpo on line 22
Process exited with code 255.
Output for 5.4.11 - 7.0.20
Catchable fatal error: Object of class Closure could not be converted to string in /in/buIpo on line 22
Process exited with code 255.
Output for 5.3.21 - 5.3.29
Catchable fatal error: Argument 1 passed to B::call() must be an instance of callable, instance of Closure given, called in /in/buIpo on line 12 and defined in /in/buIpo on line 21
Process exited with code 255.