TalkPHP

TalkPHP (http://www.talkphp.com/forums.php)
-   General (http://www.talkphp.com/general/)
-   -   Unsetting an object from within itself (http://www.talkphp.com/general/2861-unsetting-object-within-itself.html)

delayedinsanity 05-29-2008 03:23 PM

Unsetting an object from within itself
 
This may be pretty basic, but I can't think of how right now. I'm wondering if I can unset an object when a specific method is called (no, not __destruct, I don't want to have to unset() it for the method to do what it needs to do). I've been playing around with building a small template class so that I can remove all email message bodies from the program logic and have them placed in seperate .tpl files, along with some common menu's etc. So when I call my class, I do something to this effect;

PHP Code:

$pTmpl tuatara::load('functions''template'$szFilename);

$pTmpl->set('username',   $pSession->whoAmI('username'));
$pTmpl->set('profileURL'URL_USERINFO);
$pTmpl->set('adminURL',   URL_ADMIN);
$pTmpl->set('logoutURL',  URL_LOGOUT);

echo 
$pTmpl->parse(); 

What I want it to do is unset the $pTmpl object when parse() is called, instead of calling unset($pTmpl); after the fact - sounds lazy? Probably, but I'm just curious if I can do it.
-m

xenon 05-29-2008 08:38 PM

You can put a call to the destructor in the parse method (after you've done what you needed).

delayedinsanity 05-29-2008 09:00 PM

Yeah I thought of and tried that, and while I can define a destructor to clear all the properties data, it still doesn't destroy the object. I guess it's not a big deal to just unset the darned thing. :)
-m


All times are GMT. The time now is 07:16 PM.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0