When should I use static methods in a class and what are the benefits?
Posted
by NAVEED
on Stack Overflow
See other posts from Stack Overflow
or by NAVEED
Published on 2010-01-17T06:10:45Z
Indexed on
2010/03/26
5:33 UTC
Read the original article
Hit count: 300
I have concept of static variables but what are the benefits of static methods in a class. I have worked on some projects but I did not make a method static. Whenever I need to call a method of a class, I create an object of that class and call the desired method.
Static variable in a method holds it's value even when method is executed but accessible only in its containing method but what is the best definition of static method? Is calling the static method without creating object of that class is the only benefit of static method? What is the accessible range for static method? What is the syntax to create and calling static method in php?
Thanks
© Stack Overflow or respective owner