3v4l.org

run code in 300+ PHP versions simultaneously
<?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();
Output for 7.0.0 - 7.0.1
Parse error: syntax error, unexpected '}', expecting ',' or ';' in /in/LtknB on line 20
Process exited with code 255.
Output for 5.5.24 - 5.5.30, 5.6.8 - 5.6.16
Parse error: syntax error, unexpected '(' in /in/LtknB on line 12
Process exited with code 255.

preferences:
163.38 ms | 1395 KiB | 25 Q