import 'console'; class Test1 { public void __construct() { Console::Print("Test1::__construct() called.\n"); } public void __destruct() { Console::Print("Test1::__destruct() called.\n"); } } class Test2 extends Test1 { public void __construct() { Console::Print("Test2::__construct() called.\n"); $parent->__construct(); } public void __destruct() { Console::Print("Test2::__destruct() called.\n"); $parent->__destruct(); } } class Program { object $test; public void __construct() { Console::Print("Program::__construct() called.\n"); $this->test = new Test1(); } public void __destruct() { Console::Print("Program::__destruct() called.\n"); } public void main() { Console::Print("Program::main() called.\n"); object $test = new Test2(); } }