O'Reilly logo

PHP 5 CMS Framework Development by Martin Brampton

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

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 ...

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