In C, Java and PHP, the keyword static can be applied either to static methods or static variables. While there are subtle differences, the following applies to all three languages.
A static method can be called directly, without first creating an explicit object reference first. This is very handy for the singleton pattern, where you want one and only one instance of an object.
A static variable retains it value, even after the method ends. This is very handy for counter variables that increase each time the method is called.
- General – http://en.wikipedia.org/wiki/Static_method#Static_methods, http://en.wikipedia.org/wiki/Static_variable
- C – http://www.numbergrinder.com/2008/12/static-constant-strings-in-objective-c/
- Java – http://www.javacoffeebreak.com/faq/faq0010.html
- PHP – http://webreflection.blogspot.com/2007/03/php-5-developers-teach-us-what-does.html