Home > PHP Framework > ThinkPHP > body text

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

藏色散人
Release: 2021-03-30 09:13:58
forward
4234 people have browsed it

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;
        ]
    ]
];
Copy after login

3. Call the test.php configuration file

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

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

Output:

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

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

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!

Related labels:
tp6
source:csdn.net
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template