Home  >  Article  >  PHP Framework  >  Thinkphp6 custom configuration file and call (configuration under the config folder)

Thinkphp6 custom configuration file and call (configuration under the config folder)

藏色散人
藏色散人forward
2021-03-26 17:36:104175browse

The following tutorial column of thinkphp will introduce to you the Thinkphp6 custom configuration file and the method of calling (configuration under the config folder). I hope it will be useful to friends who need it. help!

Thinkphp6 custom configuration file and call (configuration under the config folder)

1. Create a new test.php configuration file under thinkphp\config\

2.test.php

<?php
// 自定义配置文件
return [
    &#39;profile&#39; => [
        &#39;name&#39; => &#39;mmcike&#39;,
        &#39;bank&#39; => [
            &#39;ABC&#39; => &#39;123&#39;,
            &#39;ncaa&#39;
        ]
    ]
];

3. Call the test.php configuration file

// 1.调用整个数组
$testConfig = \think\facade\Config::get(&#39;test&#39;);

//注意
//test.php 就是配置文件名称

Output:

// 2.只调用键名 profile 下的数组
$profile = \think\facade\Config::get(&#39;test.profile&#39;);
输出:

// 3.调用索引键的数组
$val = \think\facade\Config::get(&#39;test.profile.bank.0&#39;);
输出:

The above contains the calling forms of most arrays.

Related recommendations: The latest 10 thinkphp video tutorials

The above is the detailed content of Thinkphp6 custom configuration file and call (configuration under the config folder). For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:csdn.net. If there is any infringement, please contact admin@php.cn delete