The Singleton Design Pattern for PHP
By Tony Marston2005-07-29
References
The scope of a variable is the context in which it is defined, in this case a function or a class method. Normally the contents of a local variable are lost when program execution leaves this scope, but by defining a variable as 'static' you allow it to retain its value so that when program execution returns the previous value is still there. This value may be modified as many times as is required (as in the third example with the expanding array), so the term 'static' should not be confused with 'fixed, stable, stationary, not changing or moving'.
This is known as the scope resolution operator and allows a class method to be executed without the need for instantiating an object of that class. So instead of $object->method() you use class::method().
Tutorial Pages:
» Introduction
» A non-class Helper function
» A separate Helper method within each class
» A single Helper method for all classes
» References
» Conclusion
