3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php class A { function __destruct() { echo "a dtor\n"; global $b; $b->doSomething(); } } class B { function __destruct() { echo "b dtor\n"; } function doSomething() { echo "b still alive\n"; } } $a = new A; $b = new B;
Output for 7.0.0 - 7.1.0
b dtor a dtor Fatal error: Uncaught Error: Call to a member function doSomething() on null in /in/dP2Ev:2 Stack trace: #0 [internal function]: A->__destruct() #1 {main} thrown in /in/dP2Ev on line 2
Process exited with code 255.
Output for 5.0.0 - 5.1.6, hhvm-3.10.0 - 3.12.0
a dtor b still alive b dtor
Output for 5.6.0 - 5.6.28
b dtor a dtor Fatal error: Call to a member function doSomething() on null in /in/dP2Ev on line 2
Process exited with code 255.
Output for 5.2.0 - 5.3.29, 5.4.7 - 5.5.37
b dtor a dtor Fatal error: Call to a member function doSomething() on a non-object in /in/dP2Ev on line 2
Process exited with code 255.
Output for 5.4.0 - 5.4.6
b dtor a dtor Fatal error: Call to a member function doSomething() on a non-object in /in/dP2Ev on line 2
Output for 4.3.0 - 4.4.9