public static function getInstance() { if (empty(self::$instance)) { self::$instance = new self(); } return self::$instance; }
private static function getInstance() { if (is_null(self::$instance)) { $config = (require app_path('config/app.php')); self::$instance = new self($config); } return self::$instance; }
/** * 创建一个AppConfig对象实例 * @param $config_file * @param $options * @return AppConfig */ public static function getInstance($config_file, $options = null) { if (is_null(self::$instance)) { self::$use_apc_cache = function_exists('apc_fetch'); // 验证配置文件路径的正确性 self::checkConfigPath($config_file); // 先尝试从缓存中反序列化 self::$instance = self::getConfigFromCache($config_file); if (empty(self::$instance)) { // 创建一个新的AppConfig对象 self::$instance = new self($config_file, $options); // 将对象序列化后写入缓存 self::writeConfigToCache($config_file, self::$instance); } } return self::$instance; }