Thinkphp6自定义配置文件以及调用(config文件夹下的配置)

 2771

下面给大家介绍Thinkphp6自定义配置文件以及调用(config文件夹下的配置)方法,希望对需要的朋友有所帮助!

Thinkphp6自定义配置文件以及调用(config文件夹下的配置)

1、在thinkphp\config\下新建一个test.php配置文件


Thinkphp6自定义配置文件以及调用(config文件夹下的配置)


2、test.php

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

3、调用test.php配置文件

// 1.调用整个数组
$testConfig = \think\facade\Config::get('test');
 
//注意
//test.php 就是配置文件名称


Thinkphp6自定义配置文件以及调用(config文件夹下的配置)


输出:


Thinkphp6自定义配置文件以及调用(config文件夹下的配置)


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

输出:


Thinkphp6自定义配置文件以及调用(config文件夹下的配置)


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

输出:

ncaa


本文网址:https://www.zztuku.com/detail-8744.html
站长图库 - Thinkphp6自定义配置文件以及调用(config文件夹下的配置)
申明:如有侵犯,请 联系我们 删除。

评论(0)条

您还没有登录,请 登录 后发表评论!

提示:请勿发布广告垃圾评论,否则封号处理!!

    编辑推荐