3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Main { public function run() { echo "Deep item"; } } class Maker { public function getText() { return function () { echo "Ran"; return function () { return function () { return new Main(); }; }; }; } } class Tester { private $param; public function __constructor($param) { $this->param = $param; } public function go() { $this->param->run(); } } echo "\n instantiate Maker:\n"; $maker = new Maker(); echo "\n instantiate Tester:\n"; $tester = new Tester($maker->getText()); echo "\n Run Tester:\n"; $tester->go();
Output for 7.0.0 - 7.0.20, 7.1.0 - 7.1.20, 7.2.6 - 7.2.33, 7.3.16 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
instantiate Maker: instantiate Tester: Run Tester: Fatal error: Uncaught Error: Call to a member function run() on null in /in/XvGoc:35 Stack trace: #0 /in/XvGoc(44): Tester->go() #1 {main} thrown in /in/XvGoc on line 35
Process exited with code 255.
Output for 5.6.8 - 5.6.28
instantiate Maker: instantiate Tester: Run Tester: Fatal error: Call to a member function run() on null in /in/XvGoc on line 35
Process exited with code 255.
Output for 5.5.24 - 5.5.35
instantiate Maker: instantiate Tester: Run Tester: Fatal error: Call to a member function run() on a non-object in /in/XvGoc on line 35
Process exited with code 255.

preferences:
168.27 ms | 401 KiB | 181 Q