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

Post new comment

The content of this field is kept private and will not be shown publicly.
If you have a Gravatar account, used to display your avatar. If you have a Gravatar account, used to display your avatar.
  • Allowed HTML tags: <img> <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <span> <fn>
  • Lines and paragraphs break automatically.
  • Textual smileys will be replaced with graphical ones.
  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>. Beside the tag style "<foo>" it is also possible to use "[foo]".
  • Use [fn]...[/fn] (or <fn>...</fn>) to insert automatically numbered footnotes.

More information about formatting options

What is 39 + 48?
To combat spam, please solve the math question above.
Honey Pot that kill bots