如何详细掌握ThinkPHP5.1中Config配置项的获取与设置方法?
- 内容介绍
- 文章标签
- 相关推荐
本文共计412个文字,预计阅读时间需要2分钟。
首先需要在控制器类中引入Config类,并使用新增的facade进行配置的静态调用。以下是简化后的代码:
phpnamespace app\index\controller;use think\facade\Config;
class index{ public function index() { // 使用facade获取配置 $configValue=Config::get('app.debug'); // 后续逻辑... }}
首先需要在控制器内引入Config类,这里使用5.1新增的facade,通过facade可以静态的调用原本需要被继承才能使用的方法。
本文共计412个文字,预计阅读时间需要2分钟。
首先需要在控制器类中引入Config类,并使用新增的facade进行配置的静态调用。以下是简化后的代码:
phpnamespace app\index\controller;use think\facade\Config;
class index{ public function index() { // 使用facade获取配置 $configValue=Config::get('app.debug'); // 后续逻辑... }}
首先需要在控制器内引入Config类,这里使用5.1新增的facade,通过facade可以静态的调用原本需要被继承才能使用的方法。

