I've just been playing around with PHP5 beta for windows to get used to the new way it does classes and constuctors, etc, and have found the following...
I have a base class which has both a constructor and a destructor. I have a second class that extends the first. I then instantiate the second class. (see code below) As expected, the base class's constructor is called automatically. But when the script ends, it doesn't automatically call the base class's destructor (as I would expect). However, if I put a destructor in the derived class, it (second class's destructor) does get called. Is this a bug or is there some reason for this? If it is a bug, does anyone know off hand if this has already been reported (otherwise I'll check...)? ---- START eg1 ---- <? class test1 { function __construct() { echo "test1->con()\n"; } function __destruct() { echo "test1->de()\n"; } // doesn't get called } class test2 extends test1 { } $x = new test2(); ?> ---- END eg1 ---- ---- START eg2 ---- class test1 { function __construct() { echo "test1->con()\n"; } function __destruct() { echo "test1->de()\n"; } } class test2 extends test1 { function __destruct() { echo "test2->de()\n"; } // does get called } $x = new test2(); ---- END eg2 ---- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php