Reverse destruction

From: Date: Mon, 02 Jan 2006 12:11:45 +0000
Subject: Reverse destruction
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-228083@lists.php.net to get a copy of this message
Is it possible to reverse class __destruct() instead of following the class initiations? It makes more sence to me to close objects in last start first close. <?php class Class1 { function __construct() { echo 'Constructing ' . __CLASS__ . "\n"; } Function __destruct() { echo 'Destructing ' . __CLASS__ . "\n"; } } class Class2 { function __construct() { echo 'Constructing ' . __CLASS__ . "\n"; } Function __destruct() { echo 'Destructing ' . __CLASS__ . "\n"; } } class Class3 { function __construct() { echo 'Constructing ' . __CLASS__ . "\n"; } Function __destruct() { echo 'Destructing ' . __CLASS__ . "\n"; } } $Class1 = new Class1(); $Class2 = new Class2(); $Class3 = new Class3(); ?> Would output, Constructing Class1 Constructing Class2 Constructing Class3 Destructing Class1 Destructing Class2 Destructing Class3 I'd like for it to do: Constructing Class1 Constructing Class2 Constructing Class3 Destructing Class1 Destructing Class2 Destructing Class3 Constructing Class1 Constructing Class2 Constructing Class3 Destructing Class3 Destructing Class2 Destructing Class1 Destructing the last started object first

« previous php.general (#228083) next »