| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- <?php
- namespace app\lib;
- /**
- * Created by PhpStorm.
- * User: Administrator
- * Date: 2019/5/20
- * Time: 9:17
- */
- class GlobConfigs {
- public static $file = '';
- public static $configs = [] ;
- public static $isload = false ;
- private static $instance = null ;
- public static function getInstance(){
- if (self::$instance){
- return self::$instance;
- }
- self::$instance = new GlobConfigs();
- return self::$instance ;
- }
- public static function getKey($key,$default=''){
- if (!self::$isload) { self::load(); }
- if (isset(self::$configs[$key])){
- return self::$configs[$key];
- }
- return $default ;
- }
- public static function setKey($key,$val){
- if (!self::$isload) { self::load(); }
- self::$configs[$key] = $val;
- }
- public static function getAll(){
- if (!self::$isload) { self::load(); }
- return self::$configs ;
- }
- public static function load($file=''){
- if ( self::$isload ){ return true ; }
- if (empty($file)){
- $file = CONFIG_PATH.DS.'configs.php';
- }
- self::$configs = require_once ($file);
- self::$isload = true ;
- }
- }
|