Quote
For example: with the property $name (in object $stefan) you could get its value like so:
$name = $stefan->name;
Though doable, it is considered bad practice to do it because it can lead to trouble down the road. You should use getter methods instead - more on that later.
$name = $stefan->name;
Though doable, it is considered bad practice to do it because it can lead to trouble down the road. You should use getter methods instead - more on that later.
or in this thread
Quote
Keep in mind, there's little point in using the getters from within the object, so you may as well just use "$this->firstname" rather than "$this->get_firstname()" and make it slightly easier on PHP. The getters are there to access your object's properties from "outside" the object, so you can control how they are accessed or used.
My question is, what problems am I avoiding by creating setter classes? I have a class I'm working on now that just seems bloated by all the getter and setter methods.

Help










