I have a PHP library function expecting a callback with no arguments.
I know I can pass an object’s method with array($this , 'my_function_name')
but how can I give parameters to the my_function_name
?
I have found a solution using create_function
but from PHP manual I see it has security issues.
Advertisement
Answer
$that = $this; $wrapper = function() use($that) { return $that->my_function_name('arg1', 'arg2'); };