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');

輸出:

以上包含了大多數數組的調用形式。

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章