/ Published in: PHP
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
class Config { private static $instance = null; private $file_name = 'config'; private $file_extention = 'txt'; private $split_letter = ':'; private $config; private function __construct() { $this->config = $this->parse($this->file_path . '/' . $this->file_name . '.' . $this->file_extention); } private function prase($file) { if(file_exist($file)) { } foreach($data as $key => $value) { $config[$split[0]] = $split[1]; } return $config; } public static function getInstance() { if (self::$instance === NULL) { self::$instance = new Config(); } return self::$instance; } public function __get($var) { return $this->config[$var]; } private function __clone() {} } // config.txt could be // format: key:value language:en controller:1