示例#1
0
 /**
  * Loads data from a text/plain file as INI data and put it into the _ENV array.
  */
 public function loadEnv($file)
 {
     if (is_file($file)) {
         $data = @parse_ini_file($file, false);
         if (is_array($data)) {
             foreach ($data as $key => $value) {
                 $key = Sanitize::toKey($key);
                 $value = Utils::unserialize($value);
                 if (empty($key) || is_numeric($key) || is_string($key) !== true) {
                     continue;
                 }
                 if (array_key_exists($key, $_ENV)) {
                     continue;
                 }
                 putenv($key . "=" . $value);
                 $_ENV[$key] = $value;
             }
         }
     }
 }