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 hSGvj
Output for 7.0.0 - 7.2.0
Fatal error: Uncaught Error: Using $this when not in object context in /in/l2Fmn:6 Stack trace: #0 /in/l2Fmn(9): {closure}() #1 /in/l2Fmn(9): Closure->__invoke() #2 {main} thrown in /in/l2Fmn 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/l2Fmn 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/l2Fmn on line 8
Process exited with code 255.