16 lines
394 B
PHP
16 lines
394 B
PHP
<?php
|
|
function loadEnv($path) {
|
|
if (!file_exists($path)) {
|
|
throw new Exception('.env file not found.');
|
|
}
|
|
|
|
$lines = file($path, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
|
|
foreach ($lines as $line) {
|
|
if (strpos($line, '=') !== false) {
|
|
list($key, $value) = explode('=', $line, 2);
|
|
$_ENV[$key] = trim($value);
|
|
}
|
|
}
|
|
}
|
|
?>
|