The unregister_tick_function Function
The unregister_tick_function
function removes a function from the list of functions
executed on each tick. It takes the name of the function to be removed as a parameter.
The function returns true
on success
and false
on failure.
Syntax
unregister_tick_function(callable $function);
Example
Let's register and then unregister a function:
<?php
function tick_handler() {
echo "Tick\n";
}
register_tick_function('tick_handler');
declare(ticks=1) {
$i = 0;
while ($i < 3) {
echo "Loop $i\n";
$i++;
}
}
unregister_tick_function('tick_handler');
// Now the tick_handler function will not be called
$i = 0;
while ($i < 3) {
echo "After unregister $i\n";
$i++;
}
?>
Execution result:
Loop 0
Tick
Loop 1
Tick
Loop 2
Tick
After unregister 0
After unregister 1
After unregister 2
Example
Attempting to unregister a non-existent function:
<?php
$res = unregister_tick_function('non_existent_function');
var_dump($res);
?>
Execution result:
false
See Also
-
the
register_tick_function
function,
which registers a function for execution on each tick