天天看点

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

框架配置文件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}