The declare statement is used to temporarily change the state of the parser in a block of code. Here's how it looks:
function tick()
{
static $i;
printf("[tick i=%d]\n", ++$i);
}
register_tick_function("tick");
declare (ticks = 2) {
1; 2; 3;
}
|
Ticks is well suited for implementing simple multitasking, backgrounded IO and many other things in PHP.
See also register_tick_function() and unregister_tick_function().