Created
November 7, 2013 14:13
-
-
Save cs278/7355160 to your computer and use it in GitHub Desktop.
Fetch environment even if the $_ENV superglobal is unset due to the `variables_order` INI setting.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function getEnvironment() { | |
if ($_ENV) { | |
return $_ENV; | |
} | |
$keys = array_keys($_SERVER); | |
return $_ENV = array_filter( | |
array_combine( | |
$keys, | |
array_map('getenv', $keys) | |
), | |
'is_string' | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment