O'Reilly logo

Core PHP Programming, Third Edition by Leon Atkinson

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

3.7. Declare

The declare statement marks a block of code for execution under a set of conditions. Figure 3.8 shows the form of a declare statement.

Figure 3.8. The declare statement.
						declare(directive)
{
    Zero or more statements
}

At the time of writing, PHP accepts only one directive: ticks. The ticks directive paired with the register_tick_function cause PHP to pause execution of a script periodically to execute a function. Each tick represents a lowest-level event determined by the parser. This functionality is not meant for general programming, and PHP does not guarantee any matching between the number of ticks and the number of statements inside the declare block. Listing 3.14 shows an example of a registered tick function.

Listing 3.14. ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required