class conf {
private static $file;
private static $data;
public function __construct($file) {
self::$file = $file;
}
public static function get($section, $name=null) {
if (self::$data === null) {
self::$data = parse_ini_file(self::$file, true);
if (self::$data === false) {
throw new Exception('Файл отсутствует');
}
}
if (array_key_exists($section, self::$data)) {
if ($name && array_key_exists($name, self::$data[$section])) {
return self::$data[$section][$name];
} else {
return self::$data[$section];
}
} else {
return false;
}
}
}
Подпись:
new conf('ini/access.ini');
echo conf::get($sections, $mode);