🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
[TOC] #### $_GPC 全局请求常量, 获取 $_GET, $_POST, $_COOKIES 中的变量 #### $_G 配置相关 **$_G**(大写G),是系统中最为重要的全局变量,系统中很多常用的数据都存储在这个变量之中,下面我们详细讲解一下此变量的结构 使用示例: ~~~ public function index() { global $_G,$_GPC; p($_G); $this->display('index/index'); } ~~~ 输出结果: ~~~ Array ( [config] => Array ( [DEFAULT_PAGE] => 10 [HTTP] => http [MASTER] => app [ADDONS] => addons [TPL] => tpl [TPL_DEFAULT] => bootstrap [TPL_STATUS] => [ATTACHMENT] => attachment ) [database] => Array ( [database_type] => mysql [database_name] => calfbaby [server] => 127.0.0.1 [username] => root [password] => 123456 [charset] => utf8 [port] => 3306 [prefix] => calf_ ) [APP_URL] => http://www.calfbb.com/index.php [APP] => http://www.calfbb.com/ [ATTACHMENT_ROOT] => http://www.calfbb.com/attachment ) ~~~ 配置 | 变量名称 | 类型 | 说明 | 示例 | | --- | --- | --- | --- | | $_G['config'] | array | 主设置 | | | $_G['database'] | array | 当前数据库配置 | | | $_G['cache'] | array | 缓存配置 | | | $_G['file'] | array | 文件上传配置 | | | $_G['log'] | array | 日志配置 | | | $_G['route'] | array | 路由配置 | | | $_G['system'] | array | 系统相关配置 | | #### $_G 常量相关 | 常量名称 | 说明 | 示例 | | --- | --- |--- | | $_G['APP_URL'] | 当前web域名下入口文件 | http://www.calfbb.com/index.php | | $_G['APP'] | 当前web域名 | http://www.calfbb.com | | $_G['ATTACHMENT_ROOT'] | web上传附件目录 | http://www.calfbb.com/attachment | #### 预定义全局常量 | 常量名称 | 说明 | 示例 | | --- | --- |--- | | CALFBB | 系统根目录 | /data/test/calfbb | | APP | 定义当前模块绝对路径 | /data/test/calfbb/模块名/ | | MODULE | 定义当前模块名称 | app | | ATTACHMENT_ROOT | //==附件地址绝对路径 | /data/test/calfbb/attachment/ |