unset () variável estática não funciona?
Veja este código:http: //codepad.org/s8XnQJP
function getvalues($delete = false)
{
static $x;
if($delete)
{
echo "array before deleting:\n";
print_r($x);
unset($x);
}
else
{
for($a=0;$a<3;$a++)
{
$x[]=mt_rand(0,133);
}
}
}
getvalues();
getvalues(true); //delete array values
getvalues(true); //this should not output array since it is deleted
Resultado
array before deleting:
Array
(
[0] => 79
[1] => 49
[2] => 133
)
array before deleting:
Array
(
[0] => 79
[1] => 49
[2] => 133
)
Por que é a matriz,$x
não está sendo excluído quando está sendo desconfigurado?