Re: Shutdown order



Thomas Mlynarczyk wrote:
Also sprach Jerry Stuckle:


It doesn't make any difference what order the functions are in - they
are only called when your code calls them directly or indirectly
(i.e. a constructor). So whatever order you call them in is the way
they will be called.


But I am not /calling/ these functions - it is PHP that decides when to call them. I am merely registering two functions and instantiating an object.


As for the variable - the object is destroyed, the destructor is
called. But that's not what's happening here. You are calling the
destructor, so it acts just like any other function.


Where am *I* calling the destructor in my code? I am merely /defining/ the function __destruct() and I leave it up to PHP to decide when it is to be executed.


Rather, the destructor is called implicitly during script termination
or when the variable goes out of scope. Like a constructor, you
should not be calling a destructor.


But I am not calling it! Where in my code do I have a line that says "$o->__destruct();"?

Greetings,
Thomas



Oops, I misread your code and your post.

No, you cannot rely on the order in which things are cleaned up. It is always subject to change.

This is no different than C++, Java or any other OO languages. The order in which things are cleaned up is never guaranteed.



--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@xxxxxxxxxxxxx
==================
.



Relevant Pages

  • Re: Unusual usage of IUknown
    ... ptA = new A; ... calling V constructor, szData=V ... calling A destructor, szData=A ...
    (microsoft.public.vc.language)
  • Re: Unusual usage of IUknown
    ... char * szData; ... calling V constructor, szData=V ... calling A destructor, szData=A ...
    (microsoft.public.vc.language)
  • Re: [C++] ctors & dtors
    ... (Use and Finish could be named constructor and destructor, ... I tried calling ~foo() directly and it crashed. ...
    (comp.programming)
  • Re: gcc option for constructor and destructors
    ... I should register a routines which will be called before calling the ... function and destructor before actual return of the original function. ... Does gcc provides anything like this. ... To simulate a constructor, ...
    (comp.unix.programmer)
  • Re: Object passing
    ... crash MATLAB and/or your computer. ... Your constructor is ... calling something else which is calling the constructor ... classdef b < handle ...
    (comp.soft-sys.matlab)