...and by "properties" I actually mean "attributes" 🙂
In further reading, I see the reason has more to do with following accepted standards (as related to public and private attributes) than whether it will work (it does, in PHP4 anyway).
I also see that a popular way to access attributes from outside is to write set and get methods for each attribute you might want to access.
So you have:
function setBar($value)
{
$this->bar = $value;
}
function getBar()
{
return $this->bar;
}
The drag of this is having to write a separate function (or pair of functions) for every attribute you might want to access from outside.
Any favorite ways of getting around this? Such as...
function setAttribute($attribute_name, $value)
{
$this->$attribute_name = $value;
}
function getAttribute($attribute_name)
{
return $this->$attribute_name;
}
is this wise? Seems terribly clever, but we know how THAT always turns out...