Ambush Commander wrote:I was vaguely aware that unset() was not a real function, but that's pretty cool. Can't see any practical use for it though

If you are dealing with massive arrays or massive files, and you use unset($var) after you're done with them, would actually free the memory? I read that it would just clean up the variable namespace, but leave any allocated memory alone until the memory is required (similar to a quick versus a full format). But if casting the variable (unset)$var sets it to null (which would free the memory used), it could be easier to read.
Code: Select all
$var = array('massive size');
unset($var); //$var is undefined, but the data remains in ram until overwritten
$var = null; //will clear the memory used, but may not be clear as to why it was set specifically to null
(unset)$var; //seems to be a little clearer as to it's purpose
It's the reason why I use(d) unset(), to make it clear what it's doing. Setting a variable to null can be clear, but it can also have more than a single purpose.
I'm typing quick and I want to go home, hope you can understand my ramblings
