3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class Foo { private $callable; public function __construct() { $this->callable = function () { echo "hello world!"; }; } public function yesItDoes() { ($this->callable)(); } } class Bar { private $name; public function __construct($id) { $this->name = function ($id) { echo "Hello ".$id; }; } public function getName() { ($this->name)(); } } (new Bar('eric'))-getName(); (new Foo)->yesItDoes();
based on LtknB
Output for 7.0.0 - 7.2.0
Fatal error: Uncaught Error: Call to undefined function getName() in /in/9vRuH:29 Stack trace: #0 {main} thrown in /in/9vRuH on line 29
Process exited with code 255.
Output for 5.3.21 - 5.6.28
Parse error: syntax error, unexpected '(' in /in/9vRuH on line 12
Process exited with code 255.