register_tick_function()

register_tick_function() — Register a function for execution on each tick.

Built-in function of PHP 8.5. The manual lists it as available in PHP 4 >= 4.0.3, PHP 5, PHP 7, PHP 8. This page is the reference card: signature, parameters and return value, plus the changelog and the example the manual provides.

Signature

register_tick_function(callable $callback, mixed ...$args): bool

Parameters

ParameterTypeWhat it takes
$callbackcallableThe function to register.
...$argsmixed

Return value

Returns true on success or false on failure.

Example

A runnable snippet:

declare(ticks=1); function my_tick_function($param) { echo "Tick callback function called with param: $param\n"; } register_tick_function('my_tick_function', true);

Changelog

VersionChange
8.5.0Tick handlers are now deactivated later during request shutdown: after all shutdown functions and destructors have run, and after the output handlers have been cleaned up. Previously they were deactivated at the very beginning of request shutdown, so tick functions were no longer called during ...

See also

unregister_tick_function()

All PHP 8.5 built-in functions

Reference card built from the PHP manual page register_tick_function() (PHP documentation, CC BY 3.0). The page is generated from the manual, so the wording of the parameter and return value text follows php.net.