Archive - Feb 25, 2007

Date

Do you know about ticks?

in

in PHP, there is a declare construct.

declare(directive){
    statements;
}

this allow the directive work inside the block
declare(directive);
This allow the directive work in the entire script.

There is only one directive, which is ticks.
What does ticks do? ticks will run a function after every few "tick"(statement).
suppose you want to run something after every line of code.

function cool(){
echo 'cool';
}
register_tick_function('cool');
declare(tick=1){
    echo 'haha';
echo 'haha';
echo 'haha';
echo 'haha';
echo 'haha';
}
 
output will be hahacoolhahacoolhahacoolhahacoolhahacool

What's the point of that function?
Because my first impression is: ZOMG some new crap I will never use! yeeah!
but soon i found it have a lot more use than just show off to people and piss them off. For instance:
Keep checking if a external stuff's status
Store how much memory used by each line
Anything you just don't want to be bothered to write once after each statement

Do you know about ticks?

in

in PHP, there is a declare construct.

declare(directive){
    statements;
}

this allow the directive work inside the block
declare(directive);
This allow the directive work in the entire script.

There is only one directive, which is ticks.
What does ticks do? ticks will run a function after every few "tick"(statement).

Honey Pot that kill bots