无法在 codeigniter 中将参数作为查询字符串传递
Cannot pass parameter as a query string in codeigniter
我是 codeigniter 的新手,我想将参数作为查询字符串而不是段传递我已经看到其他链接,但它们不起作用。我只想在这个特定的控制器上使用查询字符串。下面是我正在使用的代码:
<a href="<?=base_url()?>sample_qp/new_view/?id=<?=$a2?>">
<label class="fils-label">
Reload Page
</label>
</a>
在控制器中:
public function new_view($id)
{ $id=$this->input->get('id');
$data['name']=$id;
$this->load->view('load_new_sample_view',$data);
}
我设置了
$config['enable_query_strings'] = true; and $config['uri_protocol'] =
"PATH_INFO"; but the issue is i am getting 404 page not found error.
方法01
这样传
<a href="<?=base_url()?>sample_qp/new_view/<?php echo $a2 ?>">
Make sure short_url_tag
is on
在控制器中
public function new_view($id)
{
if(empty($id))
{
echo "Invalid Token";
}
else{
echo($id);
}
}
方法02
<a href="<?=base_url()?>index.php?c=sample_qp&m=new_view&id=<?=$a2?>">
在application/config.php
$config['enable_query_strings'] = TRUE;
$config['controller_trigger'] = 'c';
$config['function_trigger'] = 'm';
在控制器中
$id = $this->input->get('id');
echo $id ;
我是 codeigniter 的新手,我想将参数作为查询字符串而不是段传递我已经看到其他链接,但它们不起作用。我只想在这个特定的控制器上使用查询字符串。下面是我正在使用的代码:
<a href="<?=base_url()?>sample_qp/new_view/?id=<?=$a2?>">
<label class="fils-label">
Reload Page
</label>
</a>
在控制器中:
public function new_view($id)
{ $id=$this->input->get('id');
$data['name']=$id;
$this->load->view('load_new_sample_view',$data);
}
我设置了
$config['enable_query_strings'] = true; and $config['uri_protocol'] = "PATH_INFO"; but the issue is i am getting 404 page not found error.
方法01
这样传
<a href="<?=base_url()?>sample_qp/new_view/<?php echo $a2 ?>">
Make sure
short_url_tag
is on
在控制器中
public function new_view($id)
{
if(empty($id))
{
echo "Invalid Token";
}
else{
echo($id);
}
}
方法02
<a href="<?=base_url()?>index.php?c=sample_qp&m=new_view&id=<?=$a2?>">
在application/config.php
$config['enable_query_strings'] = TRUE;
$config['controller_trigger'] = 'c';
$config['function_trigger'] = 'm';
在控制器中
$id = $this->input->get('id');
echo $id ;