Files
icis-inventory/includes/env_loader.php
T
2026-04-24 14:15:25 +08:00

21 lines
446 B
PHP

<?php
function loadEnv($path)
{
if (!file_exists($path)) return;
$lines = file($path, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
foreach ($lines as $line) {
if (strpos(trim($line), '#') === 0) continue;
list($key, $value) = explode('=', $line, 2);
$key = trim($key);
$value = trim($value);
putenv("$key=$value");
$_ENV[$key] = $value;
$_SERVER[$key] = $value;
}
}