将配置信息加载到库中 [英] loading configuration information in to the library
问题描述
我在 config.php
中有以下配置详细信息:
I have my configuration detail in config.php
as follows:
$config["system_images"] = "path to the folder";
我创建了自己的库 FORM
,其中我需要在 $ config [ system_images]
中使用以上值。所以我称它为 $ this-> config-> item( system_images)
。我没有加载任何配置文件,因为我使用的是默认配置文件。但是发生以下错误:
I have created my own library FORM
, in which I need to use above value in $config["system_images"]
. So I called it, $this->config->item("system_images")
. I don't load any configuration file, because I use the default configuration file. But following error occurred:
解析错误:语法错误,D:\MYSERVER\wamp中意外的'$ this'(T_VARIABLE)第3行上的\www\ci\application\libraries\Form.php
Parse error: syntax error, unexpected '$this' (T_VARIABLE) in D:\MYSERVER\wamp\www\ci\application\libraries\Form.php on line 3
我应该如何使用在
推荐答案
您需要将CodeIgniter超级对象加载到您的库中。
You need to load the CodeIgniter super object in to your library.
您可以通过以下方式对每个函数进行操作:
You can do it per function this way:
$CI =& get_instance();
$CI->config->item("system_images");
或者这样做:
class yourclass extends CI_Library {
private $CI;
function __construct() {
$this->CI =& get_instance();
}
function youfunction() {
$this->CI->config->item("system_images");
}
}
这篇关于将配置信息加载到库中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!