RE: unsetting variables

"Gavin Chalkley" <[email protected]>
Newsgroups gmane.comp.php.windows
Message-ID <[email protected]>
R P,

 

I wasn't aware that they cleaned automatically(still learning)

 

From: r p [mailto:[email protected]] 
Sent: 14 April 2012 00:10
To: Gavin
Cc: [email protected]
Subject: Re: [PHP-WIN] unsetting variables

 

You could do something like this...

    foreach (get_defined_vars() as $var => $val) {
        unset($$var, $var, $val);
    }

But this would be completely unnecessary and redundant.  At the end of a function or on return, all variables and internal reference counts within the scope of the function are essentially cleaned up or removed automatically, and garbage collection takes care of it from there (see: http://us.php.net/manual/en/features.gc.refcounting-basics.php). What specifically are you trying to accomplish or what problem are you facing?





On Mon, Apr 9, 2012 at 12:01 PM, Gavin <[email protected]> wrote:

Hello All,

Is there a way to unset all variables within a function?

Or has this got to be done on an individual basis?

-- 



Best Regards,
 
Gavin Chalkley
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.