thinkphp6自定义配置文件以及调用

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

2.test.php

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


3.调用test.php配置文件

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

输出:

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

输出:

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

输出:

以上包含了大多数数组的调用形式。

猜你喜欢

转载自blog.csdn.net/zhunju0089/article/details/103552691