3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class Foo { public $bar; public function __construct() { $this->bar = function() { return 42; }; } } $obj = new Foo(); $func = $obj->bar; echo $func(), PHP_EOL; // PHP 7 echo ($obj->bar)(), PHP_EOL;
Output for 7.0.0 - 7.2.0
42 42
Output for 5.3.17 - 5.6.28
Parse error: syntax error, unexpected '(', expecting ',' or ';' in /in/9Irkb on line 19
Process exited with code 255.