NYCPHP Meetup

NYPHP.org

[nycphp-talk] PHP 5 singleton/destructor question

Tim Gales tgales at tgaconnect.com
Fri Apr 1 13:11:35 EST 2005


Dan Cech wrote:
> David Mintz wrote:
> 
>> I think I get what you're saying... or maybe not. No instantiation, no
>> destructor runs -- I understand "static". Yet I believe an object of
>> class MyDatabase is instantiated in the example I posted earlier, and it
>> has a __destruct()  method, so its __destruct() should run when PHP
>> decides the reference count is zero. Does the reference count NOT reach
>> zero when the script terminates, no matter what? If you haven't 
>> explicitly
>> unset() or set to NULL, php cleans up the garbage for you before the
>> process ends, no?
>>
>> Maybe the register_shutdown_function() hack isn't such a bad solution.
> 
> 
> My guess would be that the destructor *is* called, just that unless you 
> manually run it, via register_shutdown_function or whatever, it's called 
> by the garbage collector *after* the page is sent to the browser...so 
> you would't see the output.
> 
> I could be totally wrong though...
> 
> Dan
>

could you trigger an error log entry in
the destructor to see for sure...

-- 
T. Gales & Associates
'Helping People Connect with Technology'

http://www.tgaconnect.com



More information about the talk mailing list