3
I am developing a function that has variables that carry a lot of data and as these variables are used only within this function it does not make sense that they continue occupying space in memory, at first I carried out the exclusion of them using the function unset()
, but I came to doubt: "After a function finishes the variables of the same are erased automatically as at the end of the script as a whole, or the use of the unset()
is really necessary?"
The function follows more or less the following structure:
<?php
function metodox($x,$y,$z)
{
//Nesse ponto a variável return recebe o resultado de uma requisição a uma API retornado pelo metodoy
$return = $metodoy($url);
$dados = json_decode($return);
//Operações sobre o conteúdo da variável $dados
//Ao fim realizo os issets
isset($return);
isset($dados);
}
I did not put the original function because it is very extensive, however, the basic structure is this.
Actually, if it is a function, I will correct the error in the question. I don’t usually use the
unset()
because from what I have seen, including in your answer in a question about the use of it, the use of it can lead to a greater memory expenditure for its execution.– Thiago Drulla