如何从我在控制器中需要的 CodeIgniter 中的配置文件中获取变量
how can get variable from config file in CodeIgniter i need in controller
我在配置文件中有这段代码:
if (isset($_GET['language']))
{
$language = base64_decode(strtr($_GET['language'], '._-', 'ABCDlanguage48+/='));
$_SESSION["language"] = $language;
$config['language'] = $language;
}
我需要在控制器 __construct
函数中使用 $language
。我怎样才能做到这一点?
我在 application/config/config.php
(文件结尾)
中添加了给定的代码
在我的 Controller
中,在 Construct
函数中添加了这样的代码:
$this->data = $this->config->item('language');
现在我可以在 Controller
.
的任何功能中使用它
赞:echo $this->data;
我在配置文件中有这段代码:
if (isset($_GET['language']))
{
$language = base64_decode(strtr($_GET['language'], '._-', 'ABCDlanguage48+/='));
$_SESSION["language"] = $language;
$config['language'] = $language;
}
我需要在控制器 __construct
函数中使用 $language
。我怎样才能做到这一点?
我在 application/config/config.php
(文件结尾)
在我的 Controller
中,在 Construct
函数中添加了这样的代码:
$this->data = $this->config->item('language');
现在我可以在 Controller
.
赞:echo $this->data;