Jasper, I would have thought php would have called the destructors on each of the classes in a LIFO fashion, but if it doesn't, just use unset() as a workaround, where you can remove the classes in the order you want. C. -----Original Message----- From: Jasper Bryant-Greene [mailto:jasper@xxxxxxxxxxxxxxxxxx] Sent: 21 July 2005 05:45 To: php-general@xxxxxxxxxxxxx Subject: objects destroyed in same order as created? ************************************* This e-mail has been received by the Revenue Internet e-mail service. ************************************* Hi all I am currently working on a PHP 5 application. For the sake of simplicity, I'll only describe 3 classes here, as that is all that is required for you to see my problem. I have a DB class that interacts with the database, a Session class that controls the session with the user, and a User class that stores the information about the logged-in user. I create instances of these classes in the order [DB, Session, User] at request startup. They have to be in this order as the Session and User classes need the database, and the User class needs the session. The User and Session destructors both need the database to write any changed information back to the database, but it seems that the destructors are called in the order that the objects are created, so the database is taken down first. Wouldn't it make more sense for just about all applications to destroy objects in the reverse order that they were created? Is there any way to work around this? Jasper -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php ************************ This message has been delivered to the Internet by the Revenue Internet e-mail service *************************