Thinkphp6自定义配置文件以及调用(config文件夹下的配置)
2022-11-24 11:10:29
210
{{single.collect_count}}

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

0f5d0d7e07c6bd3d57d82649ef96e250.png

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

7ddf510eefa1f5a24a533dd3488341ac.png

2.test.php<?php

// 自定义配置文件

return [

'profile' => [

'name' => 'mmcike',

'bank' => [

'ABC' => '123',

'ncaa'

]

]

];

3.调用test.php配置文件// 1.调用整个数组

$testConfig = \think\facade\Config::get('test');

//注意

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

fa8e784f5c7ce20459898ede5d308ae7.png

输出:

048928ffd64356c4aac4d0d9182b0ef5.png// 2.只调用键名 profile 下的数组

$profile = \think\facade\Config::get('test.profile');输出:

6b1804b953321ecbfc8f8ac958c2a6ca.png// 3.调用索引键的数组

$val = \think\facade\Config::get('test.profile.bank.0');输出:

d344a1d31e8527c5f74a69bdbc29c53e.png

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

回帖
全部回帖({{commentCount}})
{{item.user.nickname}} {{item.user.group_title}} {{item.friend_time}}
{{item.content}}
{{item.comment_content_show ? '取消' : '回复'}} 删除
回帖
{{reply.user.nickname}} {{reply.user.group_title}} {{reply.friend_time}}
{{reply.content}}
{{reply.comment_content_show ? '取消' : '回复'}} 删除
回帖
收起
没有更多啦~
{{commentLoading ? '加载中...' : '查看更多评论'}}