View Single Post
04-18-2009, 04:11 PM
Join Date: Feb 2009
Location: New York
Originally Posted by
Surely you can do them staticly, but remember you need to set the class variables to public then - which I strongly advice you not to do, 'cause then you can also accidently change the value aswell Classname::$variable = "bogus" which, needless to say, is quite a security issue.
It's safer to have a method instead to fetch a private classvariable, that way you can be sure that it's only able to return the current value, and never change it.
When/what is the appropriate time to ever set a property to "public" or is it never?
I like the idea of accessing a property value directly, it seems cleaner....or shorter than to have to create a "getter" method to get obtain the data value.
I can also see the security issue side of it, so I guess my question is:
1) why would PHP implement this if there are security issues?
2) is there ever an appropriate time set a property to public?
View Public Profile
Send a private message to allworknoplay
Find More Posts by allworknoplay