ThinkChat🤖让你学习和工作更高效,注册即送10W Token,即刻开启你的AI之旅 广告
#### 大G方法 模版引擎用于获取系统常量 使用方式: ~~~ {{ G.ATTACHMENT_ROOT }} ~~~ 输出: ~~~ http://test.calfbb.com/calfbb/attachment ~~~ 使用方式: ~~~ {{G.GPC['a']}} ~~~ 输出: ~~~ $_GET['a']; ~~~ 说明: | 名称 | 类型 |备注 | | --- | --- |--- | | G | array |全局常量,可在php代码中打印$_G查看包含内容| | GPC | array |post+get请求参数集合| | APP_URL | string |当前模块完整url | | APP | string| 当前模块路径 | | ATTACHMENT_ROOT | string| 上传附件路径 | | M | string| 当前访问模块名称 | | C | string| 当前访问控制器名称 | | A | string| 当前访问方法名称 | 原理: ~~~ /** 模版引擎用于获取系统常量扩展 * Class G * @package framework\library */ class G{ public $G; public $GPC; public $APP_URL; public $APP; public $ATTACHMENT_ROOT; public $M; public $C; public $A; public function __construct() { global $_G,$_GPC; /** * 初始化常量 */ $this->G=$_G; $this->GPC=$_GPC; $this->APP_URL=$_G['APP_URL']; $this->APP=$_G['APP']; $this->ATTACHMENT_ROOT=$_G['ATTACHMENT_ROOT']; $this->M=M; $this->C=C; $this->A=A; } public function url($url,$param=[],$suffix=true){ return url($url); } } ~~~