示例#1
0
/**
 * Gets the value of an environment variable. Supports boolean, empty and null.
 *
 * @param  string  $key
 * @param  mixed   $default
 * @return mixed
 */
function env($key, $default = null)
{
    $value = getenv($key);
    if ($value === false) {
        return $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;
    }
    if (\str::startsWith($value, '"') && \str::endsWith($value, '"')) {
        return substr($value, 1, -1);
    }
    return $value;
}
示例#2
0
function inc_multiple($pathFromWebroot, $params = array())
{
    if (!str::endsWith($pathFromWebroot, '.php')) {
        $pathFromWebroot .= '.php';
    }
    $path = dirname(__FILE__) . '/' . ltrim($pathFromWebroot, '/');
    return include $path;
}