Helping ordinary people create extraordinary websites!
HOME TUTORIALS SCRIPTS WEB HOSTING BLOG FORUM
Get Our Newsletter
Your Email:

The Singleton Design Pattern for PHP

By Tony Marston
2005-07-29


References

  • The use of the word 'static' with a local variable.

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

  • The use of the double colon '::' to call a method.

    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


     | Bookmark
    Related Tutorials:
    » Port Scanning and Service Status Checking in PHP
    » Web Database Access from Desktop Applications
    » CubeCart 3.0 Installation and Configuration
    » PHP Site Search Made Easy
    » Installing and Configuring Drupal 6.1
    » Desktop Application Development with PHP-GTK