tags:

views:

148

answers:

3

I know that Ticks are not PHP specific and are somewhat related to timing and/or number of operations, but I lack all the understanding that would otherwise allow me to work with them.

Can someone please explain to me what ticks are / do in a simple fashion?

+3  A: 

I found a decent explanation here. I have used them in writing daemons.

I think declare() might be planned for deprecation. I know it was at one point.

EDIT: It was the ticks directive that was planned for deprecation.

Chris Kloberdanz
`declare()` was never planned for deprecation, but it seems that the `ticks` directive was.
Ignas R
Yeah, you are right. The ticks=1 was required for writing daemons with pcntl functions. I just remember a comment in my code stating that something was getting deprecated.
Chris Kloberdanz
+2  A: 

this link (found via Google) says that Ticks are

a underused and powerful feature of PHP that allows you to implement exceptions in PHP4

But you're probably not talking about PHP4, in which case, go with the other answers.

pavium
Also from hte php manual http://th2.php.net/manual/en/function.register-tick-function.phpIt appears to be a low level api for debugging.
James Anderson
+1  A: 

In PHP, a tick is like an event which is triggered after every n-th statement (the n is declared using declare), with a few exceptions such as control structures (if, for, ...). It is possible to register a tick handler, which would be called every tick. This is a very rarely used feature, but sometimes it may be helpful, for example, for simple profiling.

Ignas R
So what kind of statements are considered tick-trigger statements?
Alix Axel
Well, if control structures don't count as statements, then, as far as I know, every statement can trigger a tick.
Ignas R
Damn good answer, thank you.
Alix Axel