1
foccy 2014-06-16 10:09:34 +08:00
function make()
{ $params = func_get_args(); $func = array_shift($params); return function() use ($func, $params) { return call_user_func_array($func, $params); }; } $foo = 'Foo'; $bar = 'Bar'; $sayHi = function($to, $from) { echo 'Hi, ' . $to . '. I\'m ' . $from . '.'; }; $closure = make($sayHi, $foo, $bar); $closure(); // output: 'Hi, Foo, I'm Bar.' 不知道是不是这个意思 |