3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class A { private $fruit = 'pear'; } function getfunc() { $b = function() { $a = function() { return 'apple'; }; echo $a(); }; $b->bindTo(new A()); return $this->fruit; } echo getfunc();
based on faS9c
Output for 7.0.0 - 7.2.0
Fatal error: Uncaught Error: Using $this when not in object context in /in/ME2A4:13 Stack trace: #0 /in/ME2A4(18): getfunc() #1 {main} thrown in /in/ME2A4 on line 13
Process exited with code 255.
Output for 5.4.0 - 5.6.28
Fatal error: Using $this when not in object context in /in/ME2A4 on line 13
Process exited with code 255.
Output for 5.3.19 - 5.3.29
Fatal error: Call to undefined method Closure::bindTo() in /in/ME2A4 on line 12
Process exited with code 255.