Jump to content

trying to destroy my object but can't?


ballhogjoni

Recommended Posts

I don't know why I can't unset (destroy) my object...any help?

 

class Whatever {
   function destroy(){
        unset($this);
    }
}
$asdf = new Whatever();
$asdf->destroy;

 

After this if I print_r the $asdf object it will still give me what ever values I added to it.

Link to comment
https://forums.phpfreaks.com/topic/151195-trying-to-destroy-my-object-but-cant/
Share on other sites

Why not just get rid of $asdf?

 

 

As far as I know, in PHP, it's not possible to dynamically get rid of an object from within the object.  With a language like C++ or something it could be done with some memory manipulation, but I don't know if it's possible in PHP.

 

 

By the way, you should be doing $asdf->destroy() to call a method, not destroy.

 

 

(By the way, you want to actually get rid of the object, not just unset all of it's properties, yes?)

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.