Swoole\Timer::exists

Declaration

<?php
Swoole\Timer::exists(int $timerId)\:\ bool

Parameters

timerId

The Timer ID you want to check if it exists

Return

success

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

Description

Check if a timer still exists by using the Timer ID.

Example

<?php

function run($timerId, $param1, $param2) {
    var_dump($timerId);
    var_dump($param);
}

$timerId = Swoole\Timer::tick(1000, "run", ["param1", "param2"]);

if(Swoole\Timer::exists(timerId))
{
  echo 'Yes timer does exist';
}
else
{
  echo 'No, timer does not exist';
}