guangzhou



shanghai

Recent posts:
Blog index
About
RSS

tp5在控制器中和在模板中调用配置文件中的常量

May 10, 2019     ThinkPHP   667   

框架配置文件config.php中定义

'view_replace_str'  =>  [
        '__MEMBER__'=> '/static/member',
        '__uploads__'=>'/static/uploads',
]
'TITLE'=> 'title',

控制器中

$path = config(‘view_replace_str’);

获取的是定义常量数组 如:想获得”__uploads__”的常量

$uploads = config(‘view_replace_str’)[‘__uploads__’];

获取 ‘TITLE’

$title = config(‘TITLE’);

模板中

{$Think.config.TITLE}

如果文章对您有帮助,欢迎点击下方按钮打赏作者

Comments

No comments yet.
To verify that you are human, please fill in "七"(required)