[nycphp-talk] PHP 5 singleton/destructor question
Daniel J Cain Jr.
dan at cain.sh
Fri Apr 1 02:27:36 EST 2005
Lemme try to explain again and try and make more sense.
PHP tracks the number of references to a variable, when there are no
more references it can safely be destroyed by the Zend engine. So the
count should be at 2. One for the instance you grab in the main script
and another for the static reference inside the class definition. You
need to run two unsets(one inside the class, and one outside the class)
to make that variables reference count == 0.
David Mintz wrote:
> OK, here is the ugliest workaround you've seen all day. A pint of beer for
> anyone who can explain why I am having to do this. I added to my
> constructor:
>
> register_shutdown_function(array($this, '__destruct'));
>
> and it works, so to speak.
>
> ---
> David Mintz
> http://davidmintz.org/
> _______________________________________________
> New York PHP Talk Mailing List
> AMP Technology
> Supporting Apache, MySQL and PHP
> http://lists.nyphp.org/mailman/listinfo/talk
> http://www.nyphp.org
More information about the talk
mailing list