Let's say I have a class , and in that class I have a method , and a you can use an anonymous function like this:
Class and method:
class Classe {
private $exemplo = [];
public function add($parametro1, $parametro2){
$this->exemplo['parametro1'] = $parametro1;
$this->exemplo['parametro2'] = $parametro2;
}
}
Usage:
$classe = new Classe;
$classe->add('parâmetro 1 aqui', function(){
return 'retorno da função anonima para o parâmetro 2';
});
If I give a print_r()
in the array $exemplo
of my class , the result will be as follows:
Array ( [parametro1] => parâmetro 1 aqui [parametro1] => Closure Object ( ) )
What exactly is Closure Object
and how can I get what was returned in this anonymous function ?