php闭包作为函数参数
<?php function test(Closure $call) { $a = 63; $b = 22; echo "hello"; echo $call($a,$b); } $func = function($a,$b){ return $a + $b; }; test($func); //调用顺序 先调用test ,输出hello 然后$call是个闭包,执行这个函数,传递两个值过去,想加后返回
[root@localhost swoole]# php time.php hello85[root@localhost swoole]#
- 上一篇 »PHP中的闭包function, use
- 下一篇 »PHP中的闭包function, use