dqx13503925528 2012-04-27 09:39
浏览 40
已采纳

在Codeigniter中为每个控制器启用查询字符串

Is there a way to enable query string in just one controller or for one function. For example, I want to use query string in search function, and segments in every other.

Is there a way to do this?

Can I do something like this:

$this->config->set_item('uri_protocol', 'PATH_INFO');
$this->config->set_item('enable_query_strings', TRUE);
  • 写回答

1条回答 默认 最新

  • douhe2305 2012-04-27 10:55
    关注

    A simple way to achieve this is by parsing the server query string like so.

    $get_data = array();
    
    parse_str($_SERVER['QUERY_STRING'], $get_data);
    

    This will leave you with a very insecure array full of data, so you should use CI's security class to make it more secure; so like;

    $get_data = $this->security->xss_clean($get_data);
    

    This will not mean that routing works via GET, only allow you to get the GET vars safely.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 idea运行测试代码报错问题
  • ¥15 网络监控:网络故障告警通知
  • ¥15 django项目运行报编码错误
  • ¥15 请问这个是什么意思?
  • ¥15 STM32驱动继电器
  • ¥15 Windows server update services
  • ¥15 关于#c语言#的问题:我现在在做一个墨水屏设计,2.9英寸的小屏怎么换4.2英寸大屏
  • ¥15 模糊pid与pid仿真结果几乎一样
  • ¥15 java的GUI的运用
  • ¥15 我想付费需要AKM公司DSP开发资料及相关开发。