register_tick_function

Register a function for execution on each tick

Syntax

register_tick_function ( callable $function [, mixed $... ] ) : bool

Parameters

function

The function to register.

...

Return

Returns TRUE on success or FALSE on failure.

Examples

1

<?

function myfunction() {
    echo __FUNCTION__ . PHP_EOL;
}

$function = "myfunction";

$return = register_tick_function($function);

echo $return;

?>
1

2

<?

function myfunction() {
    echo __FUNCTION__ . PHP_EOL;
}

$function = "myfunction";

register_tick_function($function);

declare(ticks = 1) {
    $a = 1;
    $b = 2;
    $c = 3;
    $d = 4;
    $e = 5;
}

?>
myfunction
myfunction
myfunction
myfunction
myfunction

3

<?

function myfunction() {
    echo __FUNCTION__ . PHP_EOL;
}

$function = "myfunction";

register_tick_function($function);

declare(ticks = 2) {
    $a = 1;
    $b = 2;
    $c = 3;
    $d = 4;
    $e = 5;
}

?>
myfunction
myfunction

4

<?

class myclass {
    static function myfunction() {
        echo __METHOD__ . PHP_EOL;
    }
}

$function = array("myclass", "myfunction");

register_tick_function($function);

declare(ticks = 1) {
    $a = 1;
    $b = 2;
    $c = 3;
    $d = 4;
    $e = 5;
}

?>
myclass::myfunction
myclass::myfunction
myclass::myfunction
myclass::myfunction
myclass::myfunction

5

<?

function myfunction() {
    echo __FUNCTION__ . PHP_EOL;
}

$function = "myfunction";

register_tick_function($function);

declare(ticks = 1);

?>
myfunction

6

<?

function myfunction() {
    echo __FUNCTION__ . PHP_EOL;
}

$function = "myfunction";

register_tick_function($function);

declare(ticks = 1);

$a = 1;
$b = 2;
$c = 3;
$d = 4;
$e = 5;

?>
myfunction
myfunction
myfunction
myfunction
myfunction
myfunction

PHP

Home Menu