All pastes #169384 Raw Edit

Miscellany

public php v1 · immutable
#169384 ·published 2006-09-13 21:21 UTC
rendered paste body
   /**    * Accessor    *    * This function allows the reading of the various    * class variables. The two ways for access are:    * - get_variablename    * - getvariablename    * @param string Name of variable    * @param mixed Value to set (not needed)    */   function __call($name, $args = null)   {      if(substr($name, 0, 4) == 'get_'){         $variable = substr($name, 4);      }      else if(substr($name, 0, 3) == 'get'){         $variable = substr($name, 3);      }      else{         // This means we have a call to a nonexistant method //         $this->ThrowException("$name: This method has no definition.");      }      if(strtolower($variable) == 'name')         return get_class($this);      foreach($this as $key => $value){         if(strtolower($variable) == strtolower($key)){            $val = $value;         }      }      return !isset($val) ? false : $val;   }