Mega Code Archive

 
Categories / Php / Class
 

Enforcing property access using magic accessor methods

<? class Person {     protected $__data = array('person', 'email');     public function __get($property) {         if (isset($this->__data[$property])) {             return $this->__data[$property];         } else {             return false;         }     }     public function __set($property, $value) {         if (isset($this->__data[$property])) {             return $this->__data[$property] = $value;         } else {             return false;         }     } } ?>