View Single Post
Old 07-14-2008, 05:00 PM   #18 (permalink)
drewbee
The Acquainted
 
drewbee's Avatar
 
Join Date: May 2008
Posts: 175
Thanks: 9
drewbee is on a distinguished road
Default

Quote:
Originally Posted by sketchMedia View Post
Static methods/variables and class constants are bound to the class therefore we must use self to reference the current class, $this however references the current object not class, remember there is a fundamental difference between the two; that is why you can't use $this 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.

edit:
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 05:14 PM. Reason: yes... google does work :D
Send a message via AIM to drewbee
drewbee is offline  
Reply With Quote