PHP Function Reference

PHP unregister_tick_function() Function



The PHP unregister_tick_function() function is used to de-register the specified function so it is no longer executed when a tick is called.

Syntax

unregister_tick_function(callback)

Parameters

callback Required. Specify the function to de-register.

Return Value

No value is returned.

Example: unregister_tick_function() example

In the example below, multiple tick handler functions are used. Each function is be called in the same order as they were registered. After few tick events one of the function is de-registered.

<?php
//functions called on each tick event
function tick_handler1() {
  echo "tick_handler1() is called\n";
}

function tick_handler2() {
  echo "tick_handler2() is called\n\n";
}

//registering tick functions
register_tick_function('tick_handler1');
register_tick_function('tick_handler2');

declare(ticks=1); //causes a tick event

$a = 1;           //causes a tick event

//de-registering first tick functions
//it also causes a tick event
unregister_tick_function('tick_handler1');

if ($a > 0) {
  $a += 3;        //causes a tick event
}
?>

The output of the above code will be:

tick_handler1() is called
tick_handler2() is called

tick_handler1() is called
tick_handler2() is called

tick_handler2() is called

tick_handler2() is called

❮ PHP Function Handling Reference

5