Create first class behaviours capable of storing state between use
Motivation
We want to maintain the history of computation, an maybe save and reuse the computation at a particular point in time
Implementation
The basic implementation is invisible in php - static variables in functions (but that doesn't allow us to have the usual features of a language with closures because functions in php are not first class objects, i.e we can't copy them), objects (they get us there, albeit more verbously).
The examples below are borrowed from io-reader: php closures. Read the post and the full code to understand the full implementation.