think\Config::has PHP Method

has() public static method

检测配置是否存在
public static has ( string $name, string $range = '' ) : boolean
$name string 配置参数名(支持二级配置 .号分割)
$range string 作用域
return boolean
    public static function has($name, $range = '')
    {
        $range = $range ?: self::$range;
        if (!strpos($name, '.')) {
            return isset(self::$config[$range][strtolower($name)]);
        } else {
            // 二维数组设置和获取支持
            $name = explode('.', $name);
            return isset(self::$config[$range][strtolower($name[0])][$name[1]]);
        }
    }

Usage Example

Example #1
0
 public function testConfig()
 {
     App::run();
     $this->assertTrue(Config::has('url_route_on'));
     $this->assertEquals(1, Config::get('url_route_on'));
     Config::set('url_route_on', false);
     $this->assertEquals(0, Config::get('url_route_on'));
     Config::range('test');
     $this->assertFalse(Config::has('url_route_on'));
     Config::reset();
 }
All Usage Examples Of think\Config::has