you can use unset($this), but it'll only work if there are no
other variables referencing to this object. unset only unsets the reference
to value, not the value itself. PHP will unset the value totally, if there
are no references to it anymore.
so using $this = null; , is perhaps the better solution.

example for unset not unsetting the value but the reference:

class test {
    var $test1 = "";
    function test($str) {
        $this->test1 = $str;
    function kill() {

$new =& new test("hallo");

$test = &$new;


echo $test->test1;

this will output hallo, although you called unset($this).

"Erik Price" <[EMAIL PROTECTED]> schrieb im Newsbeitrag
> Is there a way to unset or destroy an object instance from a method
> within its class?  I'm trying to write a method that destroys its
> instance but I'm not sure how to refer to the object itself from within
> the class.
> Erik
> ----
> Erik Price
> Web Developer Temp
> Media Lab, H.H. Brown

PHP General Mailing List (
To unsubscribe, visit:

Reply via email to