Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/codeigniter/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如何向codeigniter中的配置变量添加参数?_Php_Codeigniter_Parameters_Config - Fatal编程技术网

Php 如何向codeigniter中的配置变量添加参数?

Php 如何向codeigniter中的配置变量添加参数?,php,codeigniter,parameters,config,Php,Codeigniter,Parameters,Config,我是php新手,正在尝试向配置变量添加参数。在我的示例中,我在配置文件中定义了成功/错误消息。我可以使用以下方式访问配置变量: $this->config->item('msg') 但我想在消息中添加参数,并使用以下方法传递: $this->config->item 我该怎么做 非常感谢您的帮助。$this->config->item()工作正常 例如,如果有$config['foo']='bar'config->item('foo')的代码>将是“bar”

我是php新手,正在尝试向配置变量添加参数。在我的示例中,我在配置文件中定义了成功/错误消息。我可以使用以下方式访问配置变量:

$this->config->item('msg') 
但我想在消息中添加参数,并使用以下方法传递:

 $this->config->item 
我该怎么做

非常感谢您的帮助。

$this->config->item()
工作正常

例如,如果有
$config['foo']='bar'$this->config->item('foo')
的代码>将是“bar”

比如说

$this->config->set_item('msg', 'Your Value goes here');
你可以这样打印

echo $this->config->item('msg');

谢谢Farhan。你可以分享我的项目名称消息示例,想看看你是如何在消息中添加参数的。我可以打印消息。但该值并未反映更新后的值。在配置中,我初始化$item_value=0,在控制器中,我使用$this->config->set_item('item_value',5)更新它;该消息未显示反映的值。上面写着0。您能告诉我如何获取更新的值吗?$this->config->item('item_value');这将是5而不是$item_值,当您回显$item_值时,这将打印0,当您回显$this->config->item('item_值');这将打印5。所以配置变量不同于普通变量,谢谢Farhan。echo$this->config->item('item_value')正在从控制器打印,因为我已经在那里设置了值。在我的配置文件中,我定义了$config['item_value']=0$配置['success']=“$config['item_value'].”记录已插入。”;在我的控制器中,我有$this->config->set_item('item_value',5);echo$this->config->item('success');这是打印插入的0条记录。其中,好像我从控制器中回显$this->config->item('item_value'),打印了5条记录。我不确定我丢失了什么。
echo $this->config->item('msg');