Home >Backend Development >PHP Tutorial >How to configure scope in thinkPHP5.0 framework

How to configure scope in thinkPHP5.0 framework

不言
不言Original
2018-06-08 10:06:351522browse

This article mainly introduces the simple method of configuring the scope of the thinkPHP5.0 framework, and briefly analyzes the functions and configuration techniques of the thinkPHP5.0 scope. Friends in need can refer to the following

The examples in this article are described The thinkPHP5.0 framework simply configures the scope method. 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 entire content of this article. I hope it will be helpful to everyone’s study. For more related content, please pay attention to the PHP Chinese website !

Related recommendations:

thinkPHP5.0 framework method of accessing URL

##

The above is the detailed content of How to configure scope in thinkPHP5.0 framework. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn