3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class x { private $p = 'secret'; } $o = new x; $f = function(){ return $this->p; }; $g = $f; Closure::bind($f,$o); //echo $f->__invoke(),"\n"; echo $f(),"\n"; echo $g->call($o);
based on l2Fmn
Output for 7.0.0 - 7.2.0
Fatal error: Uncaught Error: Using $this when not in object context in /in/1lhk1:6 Stack trace: #0 /in/1lhk1(10): {closure}() #1 {main} thrown in /in/1lhk1 on line 6
Process exited with code 255.
Output for 5.4.0 - 5.6.28
Fatal error: Using $this when not in object context in /in/1lhk1 on line 6
Process exited with code 255.
Output for 5.3.19 - 5.3.29
Fatal error: Call to undefined method Closure::bind() in /in/1lhk1 on line 8
Process exited with code 255.