title: Should we always unset a class as soon as possible if we want to use complex code in __destruct?
body: <p>I have the following problem. I'm using a class and  I want to do some 'event saving (and logging)' in the __destructor method, i need to be sure that my database class is still active, and even that my memcache class is still active.</p>
  
  <p>I noticed that the destructor method can be called way too late. (database class no longer active, memcache class no longer active) </p>
  
  <p>A workaround i have found is...</p>
  
  <pre><code>$forum = new Forum_class();
  $forum-&gt;output();
  unset($forum) &lt;-- unset it
  </code></pre>
  
  <p>Is this a good practice? Or should i just skip using the destructor method to do stuff that relies on other classes being active... (available database class, available memcache class...)</p>
  
  <p>I most likely shouldn't unset my database and memcache class as soon as possible  but for the other classes, should you unset them as soon as possible. (when they are not needed on the page anymore) Or only if you want to use the __destructor function?</p>
  
  <p>Or am i doing something horrible wrong? It just seems weird to always have to make sure you unset a class. If i forget it once, my __destructor method can produce errors...</p>
  
  <p><strong>Edit</strong>: i think i stumbled upon this bug <a href="https://bugs.php.net/bug.php?id=39381" rel="nofollow">https://bugs.php.net/bug.php?id=39381</a>. My database class and memcache class use globals...</p>