讨论数量:
class a{
public static function handle(Closure $next)
{
echo 'a';
$next();
}
}
class b{
public static function handle(Closure $next)
{
echo 'b';
$next();
}
}
class c{
public static function handle(Closure $next)
{
echo 'c';
$next();
}
}
$last = function(){
echo 'last';
};
$function = function($f,$s){
return function ()use($f,$s){
$s::handle($f);
};
};
$arr = ['a','b','c'];
$handle = array_reduce($arr,$function,$last);
call_user_func($handle);
把这个复制过去运行下,应该就可以理解了。
class a{
public static function handle(Closure $next)
{
echo 'a';
$next();
}
}
class b{
public static function handle(Closure $next)
{
echo 'b';
$next();
}
}
class c{
public static function handle(Closure $next)
{
echo 'c';
$next();
}
}
$last = function(){
echo 'last';
};
$function = function($f,$s){
return function ()use($f,$s){
$s::handle($f);
};
};
$arr = ['a','b','c'];
$handle = array_reduce($arr,$function,$last);
call_user_func($handle);
把这个复制过去运行下,应该就可以理解了。
推荐文章: