RE: [PEAR] destructor not getting called.

From: Date: Thu, 06 Sep 2001 15:36:46 +0000
Subject: RE: [PEAR] destructor not getting called.
Groups: php.pear.general 
Request: Send a blank email to pear-general+get-306@lists.php.net to get a copy of this message
register_shutdown_function("_PEAR_call_destructors"); is located at the end of PEAR.php and based on the code, when php shuts down it should call _PEAR_call_destructors. Since the class "filecontainer" is an extention of "PEAR", _filecontainer is supposed to be registered as a destructor based on the call to $this->PEAR() in filcontainer's constructor. So, correct me if I'm wrong, but the way I see it is like this. PHP shuts down -> _PEAR_call_destructors is called -> _filecontainer is called. This doesn't appear to be happening. Any ideas why it wouldn't. Are there any configuration switches that need to be set inorder to allow this to work? Thanks, Matt >You have to use register_shutdown_function("_filecontainer") in >order to tell PHP what function it should use as the destructor. >In the current language syntax, there are not "automatic" >constructors in PHP. > >- Martin >>If I explicity call the destructor everything works as it should, but if I >>don't call it the appended data doesn't get written to the file. >> >><?php >> >>require_once "PEAR.php"; >> >>//class FileContainer extends PEAR >>class filecontainer extends PEAR >>{ >>[...] >> // The "destructor" is named like the constructor >> // but with an underscore in front. >> //function _FileContainer() >> function _filecontainer() >> { >> if ($this->modified) { >> $fp = fopen($this->file, "w"); >> if (!is_resource($fp)) { >> echo "not a resource file"; >> return; >> } >> fwrite($fp, $this->contents); >> fclose($fp); >> } >> } >>} >>?> _________________________________________________________ Do You Yahoo!? Get your free @yahoo.com address at http://mail.yahoo.com

« previous php.pear.general (#306) next »