If you want to block setting of public properties on your class, implement the magic setter.
class Foo {
private $data = array();
function __get($name) {
return $this->data[$name];
}
function __set($name, $value) {
if ($name != 'foo') {
$this->data[$name] = $value;
}
}
}
$f = new Foo;
$f->x = 5;
echo $f->x; // "5"
$f->foo = 'bar';
echo $f->foo; // Notice: Undefined index: foo in php shell code on
line 1
Enjoy!
David

