Swoole Server clearTimer

Notice: ext-swoole is supported until v4.7.1, use ext-openswoole >= v4.7.1. Latest version: pecl install openswoole-4.10.0

Declaration

<?php
Swoole\Server->clearTimer(int $timerId): bool

Parameters

timerId

The timer ID that you want to clear/destroy, you can get the timer ID from the return after starting one

Return

success

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

Description

Cancel the timer and destroy it immediately. Alias of function Swoole\Timer::clear.

The timer must be active within the current process.

Example

<?php
$timer_id = $server->tick(1000, function ($id) use ($server) 
{
    $server->clearTimer($id);
});