3v4l.org

run code in 300+ PHP versions simultaneously
<?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.3.27, 5.4.0 - 5.4.17
Fatal error: Cannot use $this as lexical variable in /in/ZPseQ on line 12
Process exited with code 255.

preferences:
188.06 ms | 1395 KiB | 53 Q