Posted by Mortimer on 07/19/07 13:57
Mortimer ci ha detto :
> 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"!
>
> Thank you
>
>
> Ex.:
>
> class MyFirstClass
> {
> public function __construct()
> {
> ... operations...
> }
>
> public function __destruct()
> {
> echo "Destroyed MyFirstClass";
> }
> }
>
>
>
> class MySecondClass
> {
>
> private $obj = NULL
>
> public function __construct($obj)
> {
> ... operations...
> }
>
> public function __destruct()
> {
> echo "Destroyed MySecondClass";
> }
> }
>
>
> $obj1 = new MyFirstClass();
>
> $obj2 = new MySecondClass($obj1);
>
> // Result
> // Destroyed MyFirstClass
> // Destroyed MySecondClass
I've found this:
http://bugs.php.net/bug.php?id=20240
[Back to original message]
|