Posted by gosha bine on 07/19/07 09:10
On 19.07.2007 09:39 Mortimer wrote:
> Hi, i'm using PHP 5.1
>
> I have two objects and the second one is using an instance of the first.
> As displayed in the example below, the Garbage Collector calls the
> destruct method of the first class before the second even if the second
> contains a reference to the other, so i can't complete all the
> operations not having all "the code available"!
>
> [skip]
class Database {
function __destruct() {
echo "Destroyed Database\n";
}}
class Session {
private $db;
function __construct($db) {
$this->db = $db;
}
function __destruct() {
echo "Destroyed Session\n";
}}
$sess = new Session(new Database);
prints for me
Destroyed Session
Destroyed Database
just as one can expect
what version of php are you using?
--
gosha bine
extended php parser ~ http://code.google.com/p/pihipi
blok ~ http://www.tagarga.com/blok
Navigation:
[Reply to this message]
|