ballhogjoni Posted March 26, 2009 Share Posted March 26, 2009 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 More sharing options...
corbin Posted March 26, 2009 Share Posted March 26, 2009 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?) Link to comment https://forums.phpfreaks.com/topic/151195-trying-to-destroy-my-object-but-cant/#findComment-794246 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.