Very often in code added by my more .NET oriented colleagues, I’ll run into something like this:
function someFunction()
{
$localVariable = otherFunction();
$ret = $localVariable * 2; // or whatever
$localVariable = null;
return $ret;
}
Is there any benefit to setting $localVariable to null? Since it’s a local variable (and therefore will run out of scope anyway), I would assume not, but please do correct me if I’m wrong.
Your assumption would be correct for both php and .NET.