3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class A{ public function __construct($b) { if($b) return new B(); } public function doSomethig() { echo 'A class."\n"'; } } class B{ public function __construct() { echo 'buidling B'."\n"; } public function doSomethig() { echo 'B class."\n"'; } } $c = new A(true); var_dump($c); $c->doSomething();
based on JhhAI
Output for 7.0.0 - 7.2.0
buidling B object(A)#1 (0) { } Fatal error: Uncaught Error: Call to undefined method A::doSomething() in /in/A5ZWO:28 Stack trace: #0 {main} thrown in /in/A5ZWO on line 28
Process exited with code 255.
Output for 5.3.18 - 5.6.28
buidling B object(A)#1 (0) { } Fatal error: Call to undefined method A::doSomething() in /in/A5ZWO on line 28
Process exited with code 255.