On Fri, Apr 18, 2008 at 1:02 PM, Robert Cummings <robert@xxxxxxxxxxxxx> wrote: > What he means is don't ask for the data literally (by property name) ask > for it via a method. This allows wrapping the data in "work". This is a > moot issue in PHP since PHP allows trapping the property accessor. i dont think its moot. if your trapping it via __get() or __set() its still the same action; driving the client through a well defined interface; if it just happens to have the same name as the property itself, its still the same concept. you have the 'work' in the magic methods (at a minimum the initial part), instead of the getters and setters you would build yourself. and personally, i think it much cleaner to have separate methods for each of the properties rather than one big function which has to internally route control via some sort of logic, be it conditional, variable functions or w/e. besides which, for the magic methods to work, the variables have to be 'inaccessible' according to the docs which means protected, private, or non-existent; and barring the case of non-existent we are right back in the realm of encapsulation. unless you meant something different by 'trapping the property accessor'; which you usually do pull some unexpected stuff so im waiting for your next clever example to prove me wrong :D nathan-nobbes-macbook-pro:~ nnobbe$ cat testSet.php <?php class A { public $blah; protected $meh; private $dude; function __get($var) { echo __METHOD__ . PHP_EOL; } function __set($var, $val) { echo __METHOD__ . " var: $var " . PHP_EOL; } } $a = new A(); $a->blah = 5; $a->meh = 6; $a->dude = 7; $a->fake = 8; ?> nathan-nobbes-macbook-pro:~ nnobbe$ php testSet.php A::__set var: meh A::__set var: dude A::__set var: fake -nathan