传统写法function timer () { echo "hello world"; } Swoole\Timer::tick(2000, 'timer');闭包写法Swoole\Timer::tick(2000, function () { echo "hello world"; });高级点的 传统写法$str = "hello world"; function timer () { global $str; echo $str; } Swoole\Timer::tick(2000, 'timer');闭包写法$str = "hello world"; Swoole\Timer::tick(2000, function () use ($str) { echo $str; });
查看原文:http://newmiracle.cn/?p=480
PHP匿名函数的写法
最新推荐文章于 2021-04-13 10:21:39 发布