如何使用->即讀取配置文件,讓我們快點(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');
}
}
怎么樣,看到這里,是否覺得很舒服?
官方提供的 config 服務(wù) 可取多維數(shù)組中的配置信息
列如:other.php 配置文件 , 你只需要 xxx.sss.ooo 就可以獲取到
return [ xxx=> [ sss=>[ ooo=>'你獲取到我了。' ] ] ]
更多建議: