I'm looking for advice/experience on using public variables vs private variables with accessor methods in php.
eg $obj->foo = 'a'; echo $obj->foo;
vs $obj->setFoo('a'); echo $obj->getFoo();
What I like about public variables is the shorter syntax - just seems less work to use. I understand that it could make refactoring more difficult later, but I've never experienced it (meaning, sometimes the design changes - but usually the accessor methods would need to be changed any.)
The other option is to store the variables in an array and use magic methods (_get/_set) to access them - then I have the ease of use of public variables with the ability to refactor or accessor methods.
Any experience or references of what people do in the php world.
And for anyone that hold the accessor method are the best way, is there a valid need/use for public variables?