Exploring PHP static elements and helpers
With PHP, we can declare various things static. Inside a function, by default, variables are created during the operation of the function and thrown away as the function ends. Declaring a static variable alters that behavior, so that whatever value was left in the variable at the end of one operation of the function will be found there the next time the function is called.
Inside a method, we need to be rather careful about what is meant to happen. Declaring a static variable in this situation means that the variable will be preserved across calls to the method for all objects of the class. So we cannot think in terms of one particular object having a variable that is preserved from one method call to the next, we have to think of all objects of the class together.
Often, it is better to declare a variable as static at the start of the class, outside all methods. When this is done, the variable belongs quite specifically to the class, and not to the...