Re: destructor not getting called.
| From: | Martin Jansen | Date: | Thu, 06 Sep 2001 06:24:56 +0000 |
| Subject: | Re: destructor not getting called. | ||
| References: | 1 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-304@lists.php.net to get a copy of this message | ||
On Wed, 5 Sep 2001 21:27:47 -0400, Matt Giddings wrote:
>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);
> }
> }
>}
>?>
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