Advertisement
Guest User

Untitled

a guest
Sep 20th, 2017
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.49 KB | None | 0 0
  1. <?php
  2. class getExample {
  3.     private $_values = array();
  4.     public function __get($key) {
  5.         return $this->_values[$key];
  6.     }
  7.    
  8.     public function __set($key,$value) {
  9.         $this->_values[$key]=$value;
  10.     }
  11.    
  12.     public function __call($method,$parameters) {
  13.         if (preg_match('/^get/',$method)) {
  14.             $key = preg_replace('/^get/','',$method);
  15.             $this->__get($key);
  16.         } elseif (preg_match('/^set/',$method)) {
  17.             $key = preg_replace('/^set/','',$method);
  18.             $this->__set($key,$parameters[0]);
  19.         }
  20.     }
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement