3v4l.org

run code in 300+ PHP versions simultaneously
<?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();
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
Warning: 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.5 - 7.0.20, 7.1.0 - 7.1.20, 7.2.0 - 7.2.33, 7.3.16 - 7.3.31, 7.4.0 - 7.4.33
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.3.32 - 7.3.33
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.4.0 - 5.4.45, 5.5.24 - 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.

preferences:
203.13 ms | 402 KiB | 228 Q