Created
August 25, 2017 14:00
-
-
Save jworksuk/e19eb79afeb5132c3475206c41031b90 to your computer and use it in GitHub Desktop.
env function taken from https://github.com/modess/deploying-php-applications
This file contains 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 env($key, $default = null) | |
{ | |
$value = getenv($key); | |
if ($value === false) { | |
return value($default); | |
} | |
switch (strtolower($value)) { | |
case 'true': | |
case '(true)': | |
return true; | |
case 'false': | |
case '(false)': | |
return false; | |
case 'empty': | |
case '(empty)': | |
return ''; | |
case 'null': | |
case '(null)': | |
return; | |
} | |
return $value; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment