TalkPHP
 
 
Account Login
Latest Articles
» How to keep your forms from double posting data
» cURL Basics
» Securing your PHP applications Part 1
» The way the function rolls
» Database Abstraction with Zend_Db - Part 2
Advertisement
Associates
Associates
techtuts Darkmindz
CSS Tutorials Tutorialsphere.com - Free Online Tutorials
Boston PHP SurfnLearn
Reply
 
LinkBack Thread Tools Display Modes
Old 05-29-2008, 03:23 PM   #1 (permalink)
The Gregarious
 
delayedinsanity's Avatar
 
Join Date: Mar 2008
Location: Cana'derr
Posts: 653
Thanks: 24
delayedinsanity is on a distinguished road
Default 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
delayedinsanity is offline  
Reply With Quote
Old 05-29-2008, 08:38 PM   #2 (permalink)
The Addict
 
xenon's Avatar
 
Join Date: Dec 2007
Location: Bucharest, Romania
Posts: 343
Thanks: 3
xenon is on a distinguished road
Default

You can put a call to the destructor in the parse method (after you've done what you needed).
__________________
I have optimistic thoughts, even though sometimes (if not always) life's a bitch.
xenon is offline  
Reply With Quote
Old 05-29-2008, 09:00 PM   #3 (permalink)
The Gregarious
 
delayedinsanity's Avatar
 
Join Date: Mar 2008
Location: Cana'derr
Posts: 653
Thanks: 24
delayedinsanity is on a distinguished road
Default

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
delayedinsanity is offline  
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT. The time now is 12:16 AM.

 
     

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