loadValues($path); } private function loadValues($path) { if (!is_readable($path)) throw new Exception('Cannot open config file ' . $path); $f = fopen($path, 'r'); if ($f === false) throw new Exception('Cannot open config file ' . $path); while (($line = fgets($f)) !== false) { $line = trim($line); if (substr($line,0,1) == '#') continue; if (!strlen($line)) continue; $parts = explode('=', $line, 2); $this->values[$parts[0]] = $parts[1]; } fclose($f); } public function get($name) { if (!array_key_exists($name, $this->values)) return NULL; return $this->values[$name]; } }