Note that the two methods for calling declare are not identical.
Method 1:
<?php
function do_tick($str = '') {
list($sec, $usec) = explode(' ', microtime());
printf("[%.4f] Tick.%s\n", $sec + $usec, $str);
}
register_tick_function('do_tick');
do_tick('--start--');
declare(ticks=1);
while(1) sleep(1);
?>
Method 2:
<?php
function do_tick($str = '') {
list($sec, $usec) = explode(' ', microtime());
printf("[%.4f] Tick.%s\n", $sec + $usec, $str);
}
register_tick_function('do_tick');
do_tick('--start--');
declare(ticks=1) {
while(1) sleep(1);
}
?>
Notice that when using {} after declare, do_tick wasn't auto-called until about 1 second after we entered the declare {} block. However when not using the {}, do_tick was auto-called not once but twice immediately after calling declare();.
I'm assuming this is due to how PHP handles ticking internally. That is, declare() without the {} seems to trigger more low-level instructions which in turn fires tick a few times (if ticks=1) in the act of declaring.