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:

<?php
class test {
    var $test1 = "";
    function test($str) {
        $this->test1 = $str;
    }
    function kill() {
        unset($this);
    }
}

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

$test = &$new;

$new->kill();

echo $test->test1;
?>

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

"Erik Price" <[EMAIL PROTECTED]> schrieb im Newsbeitrag
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> 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
> [EMAIL PROTECTED]
>



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to