I'm looking for how to do a callback function that does not pass as an anonymous function callback but an already declared function.
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 unfcion
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 does not work