Re: Re: Question about __destruct()

From: Date: Tue, 21 Oct 2008 21:08:41 +0000
Subject: Re: Re: Question about __destruct()
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-282216@lists.php.net to get a copy of this message
Mike van Riel schreef: > Dan Joseph wrote: >> Hi, >> >> I want to make sure I completely understand __destruct() and when its >> hit... >> >> Understand that it will run if all references to a particular object are >> removed, but is that also true when a page ends its execution? >> >> Example, I call a database class. It constructs, connects, then my page >> pulls some stuff out of the database, and then the php script ends. Does >> this also cause the deconstruct to execute? >> > > 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. >

« previous php.general (#282216) next »