TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 05-29-2008, 03:23 PM   #1 (permalink)
is cute and cuddly
 
delayedinsanity's Avatar
 
Join Date: Mar 2008
Location: Vegas, Baby
Posts: 963
Thanks: 31
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 Frequenter
Newcomer 
 
xenon's Avatar
 
Join Date: Dec 2007
Location: Bucharest, Romania
Posts: 438
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)
is cute and cuddly
 
delayedinsanity's Avatar
 
Join Date: Mar 2008
Location: Vegas, Baby
Posts: 963
Thanks: 31
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 Search this Thread
Search this Thread:

Advanced Search
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 10:12 PM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design