3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class Main { public function run() { echo "Deep item"; } } class Maker { public function getText() { 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();
based on HHIrV
Output for 7.0.0 - 7.2.0
instantiate Maker: instantiate Tester: Run Tester: Fatal error: Uncaught Error: Call to a member function run() on null in /in/lsiC2:28 Stack trace: #0 /in/lsiC2(37): Tester->go() #1 {main} thrown in /in/lsiC2 on line 28
Process exited with code 255.
Output for 5.6.0 - 5.6.28
instantiate Maker: instantiate Tester: Run Tester: Fatal error: Call to a member function run() on null in /in/lsiC2 on line 28
Process exited with code 255.
Output for 5.5.0 - 5.5.38
instantiate Maker: instantiate Tester: Run Tester: Fatal error: Call to a member function run() on a non-object in /in/lsiC2 on line 28
Process exited with code 255.