setInterval()

/**
 * This function is used to run a callback in the event loop with interval
 */
public static function setInterval(callable $callback, int $interval): SampleMacro;

The setInterval() method, repeatedly calls a function or executes a code snippet, with a fixed time delay between each call.

Example:

System::setInterval(function() {
    var_dump("Hello World!");
}, 1000);

Similar to setTimeout(), it also has a function to delete its scheduler.

$interval = System::setInterval(function() {
    var_dump("Hello World!");
}, 1000);

System::clearInterval($interval);

Last updated