I'm looking for how to make a function with callback where an anonymous function is not passed as callback but a function already declared.
I understand that to call a callback I can do it this way
private function create($callback)
{
//acciones
if(is_callable($callback)){
call_user_func($callback,$billModel);
}
}
call of the union
this->create(function($model){
echo $model;
})
but in the previous example an anonymous function is used, what I want is to pass it not an anonymous function but a function already declared for example
private function create($callback)
{
//acciones
if(is_callable($callback)){
call_user_func($callback,$billModel);
}
}
private function attachInstances($billModel)
{
//hace algo
}
//llamado de la function
$this->create($this->attachInstances)
try to make that call of the works but it doesn't work
Pass the name of the function as a parameter to.
Test: