Define a class with default accessors
*************************
class aClassName
{
public $attribute;
function __get ($name) { return $this->$name; }
function __set ($name, $value) {
if ($name == 'attribute' && $value >= 0 && $value <= 100)
$this->$name = $value;
else
echo "value out of range...";
}
}
$a = new aClassName();
$a->__set(attribute,10);
echo $a->__get(attribute)."
";
$a->__set(attribute,1000);
echo $a->__get(attribute)."
";
$a->__set(attribute,100);
echo $a->__get(attribute)."
";
// Method undefined
//echo $a->getAttribute();
*************************
10
value out of range...10
100