Page 1 of 1

PHP5 Class destructors

Posted: Thu Aug 12, 2004 2:42 pm
by dashifen
Are class destructors called when the user navigates away from a page requiring a class? For example:

Code: Select all

class foo {
  function __construct() {
    // do important stuff
  }

  function __destruct() {
     // do other important stuff
  }

  // other functions
}

Code: Select all

<?
require_once("foo.php");
bar = new foo;
?>

<!-- HTML goes here using powers of foo -->
since that "page" requires the class foo to work, will the instance of foo on the page (named bar) be "destructed" when the user navigates away from the page? When the php code is parsed? When?

Posted: Thu Aug 12, 2004 2:44 pm
by feyd
the class is destructed, likely, as soon as the page ends processing unless you've set it up in shared memory (probably)..

Posted: Thu Aug 12, 2004 2:55 pm
by dashifen
That would certainly do what I needed it to.