I'm a novice with OOP, and I'm having trouble grasping the necessity of a getter method.
In the example:
class foo {
$this->bar = "test";
}
$foo = new foo();
echo $foo->bar;
What are the potential pitfalls in this situation, assuming I'm using a setter method to properly validate an updated value?
The value of a getter method is that it lets you change your implementation later, but keep the interface the same.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With