3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class testThis { protected $_my_var = 'test'; public function getMyVar() { return $this->_my_var; } public function test() { $that = $this; $thisTest = function($otherVar) use ($that) { echo $that->getMyVar() . "\n"; echo $otherVar . "\n"; }; $thisTest("Blabla"); } } $myClass = new testThis(); $myclass->test();
based on NA77c
Output for 7.0.5 - 7.2.0
Notice: Undefined variable: myclass in /in/kLTMI on line 24 Fatal error: Uncaught Error: Call to a member function test() on null in /in/kLTMI:24 Stack trace: #0 {main} thrown in /in/kLTMI on line 24
Process exited with code 255.
Output for 7.0.0 - 7.0.4
Notice: Undefined variable: myclass in /in/kLTMI on line 24 Fatal error: Uncaught Error: Call to a member function test() on unknown in /in/kLTMI:24 Stack trace: #0 {main} thrown in /in/kLTMI on line 24
Process exited with code 255.
Output for 5.6.8 - 5.6.28
Notice: Undefined variable: myclass in /in/kLTMI on line 24 Fatal error: Call to a member function test() on null in /in/kLTMI on line 24
Process exited with code 255.
Output for 5.3.18 - 5.5.35
Notice: Undefined variable: myclass in /in/kLTMI on line 24 Fatal error: Call to a member function test() on a non-object in /in/kLTMI on line 24
Process exited with code 255.