You are here: Reverse destruction « PHP « IT news, forums, messages
Reverse destruction

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]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация