4. Class Accessors
Object accessors are a way to abstract access to an object's member variables (also known as “properties”, “attributes”, “fields”, “slots”, etc.) behind method calls. For example we can use $person->age() to get the age of $person and $person->age(21) or $person->set_age(21) to set their age to 21.
Accessors provide several important advantages over accessing the properties of objects directly and this section will serve as an introduction to them.