Swoole\Timer->tick

Declaration

<?php
Swoole\Timer->tick (int $interval_ms, callable $callback [, string[] $callback_params ])

Parameters

interval_ms

Milliseconds interval duration

callback

Callback function

callback_params

The parameters passed into the callback function

Return

success

if success, it returns TRUE, otherwise it returns FALSE.

Description

Start a timer which is calling the callback function every $interval_ms ms.

Callback function

<?php
function(int $timerid, $param) {

}

Example

<?php
function run($timerid, $param) {
    var_dump($timerid);
    var_dump($param);
}
Swoole\Timer->tick(1000, "run", ["param1", "param2"]);