phpcms二次开发配置文件调用

今天给大家介绍phpcms的二次开发,本节重点介绍下配置文件调用,phpcms已经站在巨人的肩上了,我们要驾驭这个巨人,就必须学会phpcms的二次开发,下面由程序员人生网为大家整理的配置文件调用使用方法,phpcms在开源程序中一直是佼佼者,我们必须要学会怎样使用

配置文件配置在caches/configs/目录下。

配置文件调用:使用 load_config方法

 /**
  * 加载配置文件
  * @param string $file 配置文件
  * @param string $key  要获取的配置荐
  * @param string $default  默认配置。当获取配置项目失败时该值发生作用。
  * @param boolean $reload 强制重新加载。
  */
 public static function load_config($file,$key = '',$default = '',$reload = false) {
    static $configs = array();
    if (!$reload && isset($configs[$file])) {
       if (empty($key)) {
         return $configs[$file];
       } elseif (isset($configs[$file][$key])) {
         return $configs[$file][$key];
       } else {
         return $default;
       }
    }
   $path = CACHE_PATH.'configs'.DIRECTORY_SEPARATOR.$file.'.php';
   if (file_exists($path)) {
     $configs[$file] = include $path;
   }
   if (empty($key)) {
     return $configs[$file];
   } elseif (isset($configs[$file][$key])) {
     return $configs[$file][$key];
   } else {
     return $default;
   }
 }


示例:

调用系统配置中的附件路径

$upload_url = pc_base::load_config('system','upload_url');

相关文章

本教程操作系统:Windows10系统、phpcms 9版本、Dell G3电脑...
PHPcms访问特点:单一入口模式。无论访问任何一个模块或者功...
例如:{pc:contentaction="position"posid="...
首先,上图之中的红色框框是没有的,我们想要给他加上,当然...
头部<metaname="keywords"content="{$SEO...
做网站时用的到的简单的栏目导航()phpcms多个栏目catidin(9,...