From e1276159b2abe20d311d941c22deb84cd756488e Mon Sep 17 00:00:00 2001 From: thinkphp Date: Tue, 8 Dec 2015 23:53:36 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=AD=A3config=E7=B1=BB=E7=9A=84set?= =?UTF-8?q?=E6=96=B9=E6=B3=95=E8=BF=94=E5=9B=9E=E5=80=BC=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/config.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/library/think/config.php b/library/think/config.php index b7c45b14..b899c1c1 100644 --- a/library/think/config.php +++ b/library/think/config.php @@ -22,6 +22,9 @@ class Config public static function range($range) { self::$range = $range; + if (!isset(self::$config[$range])) { + self::$config[$range] = []; + } } // 解析其他格式的配置参数 @@ -38,6 +41,9 @@ class Config public static function load($file, $name = '', $range = '') { $file = strpos($file, '.') ? $file : APP_PATH . $file . EXT; + if (!isset(self::$config[$range])) { + self::$config[$range] = []; + } return is_file($file) ? self::set(include $file, $name, $range) : self::$config[$range]; } @@ -107,7 +113,8 @@ class Config return self::$config[$range] = array_merge(self::$config[$range], array_change_key_case($name)); } } else { - return null; // 避免非法参数 + // 为空直接返回 已有配置 + return self::$config[$range]; } }