diff --git a/library/think/Env.php b/library/think/Env.php new file mode 100644 index 00000000..a23d9925 --- /dev/null +++ b/library/think/Env.php @@ -0,0 +1,31 @@ + +// +---------------------------------------------------------------------- + +namespace think; + +class Env +{ + /** + * 获取环境变量值 + * @param string $name 环境变量名(支持二级 .号分割) + * @param string $default 默认值 + * @return mixed + */ + public static function get($name, $default = null) + { + $result = getenv(ENV_PREFIX . strtoupper(str_replace('.', '_', $name))); + if (false !== $result) { + return $result; + } else { + return $default; + } + } +}