Hi all
Just want to start a little discussion about unsetting variables in php. I'd like to know your view on when unset($var) should be used...
Everytime your finished using a variable, everytime your finished using a "large" variable or never...
What's the common practise?
Personally I seldom unset variabels. Maybe I want to use the variable later, and has forgotten that somewhere the variable was unset.
I don't take unset() too seriously in other words.
regards tores
The value of unset()
Moderator: General Moderators
-
ldomingues
- Forum Commoner
- Posts: 41
- Joined: Fri Aug 06, 2004 1:15 pm
- Location: Portugal
I always use unset when i need to "delete" a value in an associative array.
For example:
For example:
Code: Select all
<?php
$fields["id"]["description"]="pkey";
$fields["id"]["value"]=10;
$fields["name"]["description"]="name";
//if you want to remove part of the array do:
unset($fields["name"]);
// for example
?>