Overview

Ticks were added to PHP 4.0.3 as a way to simulate background processing for blocks of code. They allow one or more functions to be called as a side effect of having expressions evaluated. Simply put, developers can set up functions that are called automatically as the script runs—this is useful for running functions that perform status checking, cleanup, notification, and so on. Ticks can also be indispensable for quick and dirty debugging—see the simple example below.

Note:

Used inappropriately, ticks can help you write code that behaves very strangely! You should have a solid understanding of PHP before you start using ticks in production scripts.

Get PHP Functions Essential Reference now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.