Posted by Richard Lynch on 10/16/46 11:10
> Richard Lynch wrote:
>>><?php
>>>class c1 {
>>> public function __destruct() {
>>> echo '__destruct';
>>> }
>>>}
>>>
>>>class c2 {
>>> private static $_ref;
>>>
>>> public function __construct() {
>>> self::$_ref = new c1();
>>>
>>> //$this->_ref = new c1();
>>> }
>>>}
>>>
>>>$obj = new c2();
>>>unset($obj);
>>>?>
>>>
> self::$_ref is completely independent of any instance of that class.
c2::$_ref has no value unless and until you create at least one (1) c2
instance.
That is the only dependency.
c2::$_ref cannot be destroyed by PHP unless and until the entire script is
dying because it is STATIC and if you create a second c2, it shouldn't
change, right?
So you only ever have, at most, one c1 running around.
You have no c1's until you create a c2.
Then you have 1 c1 until the script ends.
At least, that's what I'd expect from a STATIC property based on other OO
languages... Never actually used PHP's OO stuff for reasons we needn't
repeat.
--
Like Music?
http://l-i-e.com/artists.htm
[Back to original message]
|