Posted by "Mattias Segerdahl" on 01/02/06 14:11
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
Navigation:
[Reply to this message]
|