homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

is it necessary to unset all local vars?
unset all local vars

Msg#: 4579502 posted 3:16 pm on May 30, 2013 (gmt 0)

Hi everyone,

I read an article on how to code php efficiently and speedup execution and there its written that its a good practice to unset all the local variables as it will free the memory.

correct me if i am wrong? we can unset vars in the following ways:

so if i have 20 or 30 variables inside then how to unset those?

after few research i have got a build in php function get_defined_vars which lists all the variables.

is there any smart approach?

with thanks



WebmasterWorld Administrator jatar_k us a WebmasterWorld Top Contributor of All Time 10+ Year Member

Msg#: 4579502 posted 5:39 pm on May 30, 2013 (gmt 0)

all vars are freed when script execution finishes

when you are doing scripts it is good practice to reuse or unset vars as you go along to keep memory usage as low as possible, especially if you are loading large arrays and are done with them

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved