🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
# 官方文档: https://www.workerman.net/doc/workerman/timer/add.html ## 代码案例: ~~~ require_once 'workerman/Autoloader.php'; use Workerman\Worker; use Workerman\Lib\Timer; $worker=new Worker('text://0.0.0.0:8883'); $worker->onWorkerStart=function ($worker){ Timer::add(3,function (){ echo "定时器"."\n"; }); }; $worker->onConnect = function($connection) { echo "new connection from address ". $connection->getRemoteIp() . ":". $connection->getRemotePort() ."\n"; //获取端口与IP }; Worker::runAll(); ~~~