On Wed, Oct 22, 2008 at 9:42 AM, Dan Joseph <[EMAIL PROTECTED]> wrote:
> On Tue, Oct 21, 2008 at 5:14 PM, Stut <[EMAIL PROTECTED]> wrote:
>
>>
>>
>>>> When a script ends everything is released (with some small exceptions),
>>>> thus also all references to instances of classes.
>>>> Thus AFAIK a deconstructor will always be called at the end of script
>>>> execution.
>>>>
>>>>
>>> but you have no control over what order dtors are called and you can't
>>> make
>>> any assumptions about state of file handles to STDIN/STDOUT and things
>>> like
>>> that ... personally I find dtors run at end of script to be nigh on
>>> useless.
>>>
>>
>> I use destructors to update dirty objects in memcache. I also use them in
>> my template class to optionally automagically output the footer without
>> needing an explicit call on each page.
>>
>
>
> Never any issues this way?  They always run without a hitch?
>
> --
> -Dan Joseph
>
> www.canishosting.com - Plans start @ $1.99/month.
>
> "Build a man a fire, and he will be warm for the rest of the day.
> Light a man on fire, and will be warm for the rest of his life."
>

Don't throw exceptions in your dtors.  Hilarity will not ensue.  There
are some good use cases for them as others have stated, but I'd
recommend staying away unless you really need it.  I've only ever used
dtors for closing query results and gd resources.  Trivial stuff to
just try and lower the memory usage but isn't really necessary.  In
general though I stay away from them as most of my code is front-end
meaning everything is tore down at the end of the request anyways.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to