Skip to content

Instantly share code, notes, and snippets.

@jworksuk
Created August 25, 2017 14:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jworksuk/e19eb79afeb5132c3475206c41031b90 to your computer and use it in GitHub Desktop.
Save jworksuk/e19eb79afeb5132c3475206c41031b90 to your computer and use it in GitHub Desktop.
<?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