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

Notice: the documentation is suitable for PHP extension swoole until v4.7.1, we only support PHP extension openswoole from v4.7.1

Declaration

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

Parameters

event

The event callback name.

callback

Callable event function.

Return

success

If success, it returns true, otherwise it returns false.

Description

Execute the callback function when receiving Timer tick events.

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

Example

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