This article mainly introduces the thinkPHP5.0 framework simple method of configuring the scope, and briefly analyzes the functions and configuration skills of the thinkPHP5.0 scope. Friends in need can refer to the following
The example in this article describes how to simply configure the scope of the thinkPHP5.0 framework. Share it with everyone for your reference, the details are as follows:
Configuration parameters support the concept of scope, By default, all parameters are under the same system default scope. If your configuration parameters need to be used in different projects or isolated from each other, you can use the scope function . The role of the scope is like the namespace of the configuration parameters. .
// 导入my_config.php中的配置参数,并纳入user作用域 Config::load('my_config.php','','user'); // 解析并导入my_config.ini 中的配置参数,读入test作用域 Config::parse('my_config.ini','ini','test'); // 设置user_type参数,并纳入user作用域 Config::set('user_type',1,'user'); // 批量设置配置参数,并纳入test作用域 Config::set($config,'test'); // 读取user作用域的user_type配置参数 echo Config::get('user_type','user'); // 读取user作用域下面的所有配置参数 dump(Config::get('','user')); dump(config('',null,'user')); // 同上 // 判断在test作用域下面是否存在user_type参数 Config::has('user_type','test');
The above is the detailed content of Code example of simple configuration scope of thinkPHP5.0 framework. For more information, please follow other related articles on the PHP Chinese website!