如何使用?

2018-11-27 16:03 更新

使用介紹

如何使用->即讀取配置文件,讓我們快點(diǎn)往下看吧!

在目錄結(jié)構(gòu)文檔頁(yè),可以看到service服務(wù)目錄下 有 config類

演示:

<?php namespace \test\app;


use \service\config;


class test
{
    public function index()
    {
        //如果我要獲取默認(rèn)配置的debug情況
        $debug = config::get('debug');

        
        //如果我要獲取debug狀態(tài)如何
        $switch = config::get('debug.switch');


        //如果我要獲取其他配置文件的配置該如何獲取?
        $other = config::get('xxx.sss.ooo','other');
    }
}

怎么樣,看到這里,是否覺(jué)得很舒服?

官方提供的 config 服務(wù) 可取多維數(shù)組中的配置信息

列如:other.php 配置文件 , 你只需要 xxx.sss.ooo 就可以獲取到

return [ xxx=> [ sss=>[ ooo=>'你獲取到我了。' ] ] ]

以上內(nèi)容是否對(duì)您有幫助:
在線筆記
App下載
App下載

掃描二維碼

下載編程獅App

公眾號(hào)
微信公眾號(hào)

編程獅公眾號(hào)