如果
如果
我是php开发人员。我刚加入Codeigniter。我正在Codeigniter中转换我的php项目。所以我想通过url发送一些值。我知道Codeigniter的格式,比如example.com/index.php/controller/value.
但我想使用简单的php格式,如
http://example.com/index.php/controller?id=value
我想帮助做这件事,我也不知道在控制器中得到这个值。
如果<form>
所以你的表格应该像这个
<form action="<?php echo base_url();?>index.php/controller/method" method="get">
当你提交数据时,它将通过类似的URL
CodeIgniter-3/index.php/controller/method?id=25&demail=bbb
所以在控制器中
$id = $this->input->get('id'); # Output 25
$demail = $this->input->get('demail'); # Output bbb
如果<a>
<a href="<?php echo base_url();?>index.php/controller/method?id=25">clickkk</a>
所以在控制器中
$id = $this->input->get('id'); # Output 25
echo base_url("controller/test")."/".$id;
in your controller function
function test($id='')
{
}
对于类似以下格式的url:
http://example.com/index.php/controller/method/?id=value
只需在控制器方法中执行此操作
$this->input->get('your_variable', TRUE);
不要忘记config.php文件:
$config['uri_protocol'] = 'PATH_INFO';
$config['allow_get_array'] = TRUE;
$config['enable_query_strings'] = TRUE;