3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php class closurecaller { public function doSomething() { var_dump('i am called'); } public function callClosure() { $closure = function() use (&$this) { $this->doSomething(); }; return $closure; } } $cc = new closurecaller(); call_user_func($cc->callClosure());
Output for 5.3.0 - 5.4.17
Fatal error: Cannot use $this as lexical variable in /in/H8SJP on line 12
Process exited with code 255.