Swoole\Server->on('timer', fn)

Declaration

<?php
Swoole\Server->on('timer', callback $callback)

Parameters

event

The event name

callback

callback function

Return

success

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

Description

Executue the callback function when receving Timer ticks.

A Timer can be added to the server with $server->addTimer method.

Callback function

<?php
function (Swoole\Server $server, int $interval) {

}

Example