Advertisement
peterurfi

Untitled

Nov 9th, 2011
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.45 KB | None | 0 0
  1. private $_data = array();
  2.  
  3. public function __get($name) {
  4.   if (array_key_exists($name, $this->_data)) {
  5.     return $this->_data[$name];
  6.   } else {
  7.     return false;
  8.   }
  9. }
  10.  
  11. public function __set($name, $value) {
  12.   $this->_data[$name] = $value;
  13. }
  14.  
  15. [...]
  16.  
  17.  
  18. //----------------------------------------------------------------------
  19.  
  20. $obj = new MyClass();
  21. $obj->__set("min", 1);
  22. $obj->__set("max", 8);
  23.  
  24. $obj->__get("min");
  25. $obj->__get("max");
  26.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement