PDA

View Full Version : PHP5: Make an object destroy itself



FoxyForest
03-18-2007, 08:11 PM
Hey,

I'd like to have an object destroy itself (that is, so that if it was referenced in any later code, there would be a big fat PHP error about it not existing). How can I do this?

I've tried:

unset($this) //doesn't destroy it
$this = null //error
$this->__destruct //error

Inigoesdr
03-19-2007, 03:13 AM
http://bugs.php.net/bug.php?id=36971

FoxyForest
03-19-2007, 12:42 PM
Well, damn.

KeZZeR
03-19-2007, 01:23 PM
Why would you need to explicitly destroy the object though? Surely you can wait until it goes out of scope?