Hi all,
I have a class which creates a new object and caches this object (see source
at the bottom). The new object holds a link on the creator class.
The __descructor function of both classes are never called - because the
classes are destroyed (killed), when the script terminates.
Is there a way to "destruct" a class on another way manually?
Does anyone know about any deeper documentation about objects in PHP5?
Thanks!
Bye,
Thomas.
-
<?php
class a {
private $p_b;
function __construct() {
echo __CLASS__ . '::' . __FUNCTION__ . '<br>';
}
function __destruct() {
echo __CLASS__ . '::' . __FUNCTION__ . '<br>';
}
function get_b() {
if (!isset($this->b)) {
$this->b=new b($this);
}
return $this->b;
}
}
class b {
private $p_caller;
function __construct($caller) {
echo __CLASS__ . '::' . __FUNCTION__ . '<br>';
$this->p_caller=$caller;
}
function __destruct() {
echo __CLASS__ . '::' . __FUNCTION__ . '<br>';
}
}
$a=new a;
$b=$a->get_b();
unset($a);
unset($b);
?>
Just prints:
a::__construct
b::__construct
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php