How to avoid dynamic properties in PHP (raise an Error when setting an undeclared property)
Use __set() ?
<?php
class Test {
public $bar;
public function __set($name, $value) {
throw new Exception('Cant set!');
}
}
$obj = new Test;
$obj->bar = 'foo';
$obj->foo = 'evil';
?>