3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $obj = new StdClass; $obj->fn = function($arg) { return "Hello $arg"; }; echo $obj->fn->call($obj, 'World'); echo PHP_EOL; echo ($obj->fn)();
based on o7lTB
Output for 7.1.0 - 7.2.0
Warning: Cannot bind closure to scope of internal class stdClass in /in/6RgpA on line 6 Fatal error: Uncaught ArgumentCountError: Too few arguments to function {closure}(), 0 passed in /in/6RgpA on line 8 and exactly 1 expected in /in/6RgpA:4 Stack trace: #0 /in/6RgpA(8): {closure}() #1 {main} thrown in /in/6RgpA on line 4
Process exited with code 255.
Output for 7.0.0 - 7.0.20
Warning: Cannot bind closure to scope of internal class stdClass in /in/6RgpA on line 6 Warning: Missing argument 1 for {closure}(), called in /in/6RgpA on line 8 and defined in /in/6RgpA on line 4 Notice: Undefined variable: arg in /in/6RgpA on line 4 Hello
Output for 5.3.21 - 5.6.28
Parse error: syntax error, unexpected '(', expecting ',' or ';' in /in/6RgpA on line 8
Process exited with code 255.