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.

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

报告相同问题?

悬赏问题

  • ¥15 nginx中的CORS策略应该如何配置
  • ¥30 信号与系统实验:采样定理分析
  • ¥100 我想找人帮我写Python 的股票分析代码,有意请加mathtao
  • ¥20 Vite 打包的 Vue3 组件库,图标无法显示
  • ¥15 php 同步电商平台多个店铺增量订单和订单状态
  • ¥15 关于logstash转发日志时发生的部分内容丢失问题
  • ¥17 pro*C预编译“闪回查询”报错SCN不能识别
  • ¥15 微信会员卡接入微信支付商户号收款
  • ¥15 如何获取烟草零售终端数据
  • ¥15 数学建模招标中位数问题