Hi !
I'm used to unset my local variables but I'm wondering if it is really useful.
For instance, in this case:
PHP Code:
<?php
function toto()
{
$myVar=5;
[...] // some treatments
unset($myVar);
}
?>
Is the local variable $myVar automatically free when we leave the function toto or is it really useful to unset it ?
Must I just unset the variables instancied by the "new" operator ?
Second question:
I don't know if what I put in my __destruct methods is good.
Indeed, my typical __destruct method is
PHP Code:
public function __destruct()
{
foreach(get_object_vars($this) as $k=>$v)
unset($this->$k);
}
and then, my __destruct() call on an object $foo is automatically followed by unset($foo);
In fact, I don't know the exact behavior of php when it leaves a method and when it has finished to parse my pages.
What do you advise ?
Thank you, have a nice evening !