Home  >  Q&A  >  body text

Scope setting issue

public function index()

{

//Set a set of configuration items

$config = [

'user_name' => 'vivian',

'user_age' => 22,

];

//Batch settings, write to user scope

Config: :set($config,'user');

// Output all configuration items, the scope is equivalent to the name of the secondary configuration item

// dump(Config::get() );

//Use an array to configure the values ​​in the scope

Config::set('user.user_name','php_cn');

/ /View the set value

dump(Config::get('user.user_name'));

// Switch scope

Config::range(' _sys_');

//View all configuration items

dump(Config::get());

}

Batch setting method here Config:set($config,'user'); is wrong. This actually writes $config into the system scope. The correct way of writing it should be Config::set($config,'','user') ;

In addition, the configuration parameters set in the user scope should not be visible in the system configuration

宝怡宝怡1891 days ago1348

reply all(1)I'll reply

  • 像风一样自由

    像风一样自由2019-08-16 20:11:33

    I’ll go, it’s awesome!

    reply
    0
  • Cancelreply