What are the advantages of using getters and setters instead of functions or simply public fields in PHP?

QuestionsWhat are the advantages of using getters and setters instead of functions or simply public fields in PHP?
sethbeckerman5 Staff asked 15 years ago

I'm not a PHP developer, so I'm wondering what the advantages and disadvantages are in PHP to using explicit getter/setters, in a pure OOP style, with private fields (the way I like):

or just public fields:


View on Stack Overflow