The declare construct is used to set execution directives for a block of code. The syntax of declare is similar to the syntax of other flow control constructs:
The directive section allows the behavior of the declare block to be set. Currently only one directive is recognized: the ticks directive. (See below for more information on the ticks directive)
The statement part of the declare block will be executed -- how it is executed and what side effects occur during execution may depend on the directive set in the directive block.
The declare construct can also be used in the global scope, affecting all code following it.
A tick is an event that occurs for every
N low-level statements executed
by the parser within the declare block.
The value for
N is specified
within the declare blocks's
The event(s) that occur on each tick are specified using the register_tick_function(). See the example below for more details. Note that more than one event can occur for each tick.
Example 16-3. Profile a section of PHP code
Ticks are well suited for debugging, implementing simple multitasking, background I/O and many other tasks.