My First Class - Any Good?
View Single Post
07-14-2008, 05:00 PM
Join Date: May 2008
Originally Posted by
Static methods/variables and class constants are bound to the class therefore we must use
to reference the current
however references the current
not class, remember there is a fundamental difference between the two; that is why you can't use
to access methods/properties marked as static or class constants because they are bound to the class not the object.
Thanks for that explanation. I havn't used method / variable scoping to much yet, and this makes sense.
I guess my real question is, what is the purpose to making a static method vs public? I understand private, protected, and public, but not static.
Declaring class members or methods as static makes them accessible without needing an instantiation of the class.
More on visibility:
The visibility of a property or method can be defined by prefixing the declaration with the keywords: public, protected or private. Public declared items can be accessed everywhere. Protected limits access to inherited and parent classes (and to the class that defines the item). Private limits visibility only to the class that defines the item.
There are No Stupid Questions. But there a LOT of Inquisitive Idiots.
Last edited by drewbee : 07-14-2008 at
. Reason: yes... google does work :D
View Public Profile
Send a private message to drewbee
Find More Posts by drewbee