|
Posted by Jerry Stuckle on 11/16/06 23:06
Thomas Mlynarczyk wrote:
> Also sprach Jerry Stuckle:
>
>
>>This is no different than C++, Java or any other OO languages. The
>>order in which things are cleaned up is never guaranteed.
>
>
> But at least the order of "calling all shutdown functions", "calling all
> destructors" and "calling ob buffer function" should be well-determined,
> even if the order in which the destructors are called may not be guaranteed.
>
> And this still doesn't explain why I can access an object *after* its
> destructor has been called. Strange...
>
> Greetings,
> Thomas
>
>
Thomas,
No, those are all undefined.
And you can still access the object because its reference still points
to the object. PHP will destroy the object, but will not alter the
reference to the object. There is no need to - the reference will be
destroyed soon, anyway.
Destructors are meant to clean up the object itself - i.e. for a class
which access a database you could want to close the database connection.
It's never a good idea to have a destructor depend on the state of
another object which itself may be destroyed. The same is true when you
register a shutdown function - that function should not depend on the
state of any objects.
If you must do this, you need to change the destructor in your Test
object to set the state to invalid.
But that also doesn't mean it might not change again in the future. All
of the processing order is undefined.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
Navigation:
[Reply to this message]
|