3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class MyParent extends Observer { function createChild() { $this->callme(); // this is OK return new MyChild (function() { $this->callme(); }); } } class MyChild { private $gatewayFunction; public function __constructor (Closure $gatewayFunction) { $this->gatewayFunction = $gatewayFunction; } public function __destroy() { $this->gatewayFunction->__invoke(); } } $p = new MyParent(); $c = $p->createChild(); var_dump($c); $c->__destroy();
based on n9Lcs
Output for 7.0.0 - 7.2.0
Fatal error: Class 'Observer' not found in /in/kWmBf on line 3
Process exited with code 255.
Output for 5.3.17 - 5.6.28
Fatal error: Class 'Observer' not found in /in/kWmBf on line 4
Process exited with code 255.