怎么调用timer的参数

<?php
require_once _DIR_ . '/Workerman/Autoloader.php';
use Workerman\Worker;
use Workerman\Lib\Timer;

$w = new \Workerman\Worker(); 
$w->onWorkerStart=function(){ 
   $timer_id=Timer::add(1, function ($client_id) {
         var_dump(time() . " " . $client_id);
},,true);

     Timer::add(10,function()use($timer_id){
           var_dump('check timer id : '.$timer_id);
            var_dump('check client id : '.$client_id); <- 怎么把$client_id 值放这个地方
      },,false);
}; 
?>
已邀请:

blogdaren - 喜欢分享的PHP码农【http://www.blogdaren.com】

赞同来自: callplay

试试:
$worker = new Worker(); 
$worker->onWorkerStart = function($worker){
//assume $client_id = 100
Timer::add(1, function($client_id = 100)use($worker){
$worker->client_id = $client_id;
}, array(), true);

Timer::add(2, function()use($worker){
var_dump('get client id : '. $worker->client_id);
}, [], false);
};

要回复问题请先登录注册