dtvjl64442 2016-11-26 09:31
浏览 47


I'm trying to paginate the search results returned by the query. I have the following URL:


Where I am trying to get the value of $start=5 from the URL using:

$start = $this->uri->segment(3);

It is not returning anything.

Where removing ?query=post, i.e, blog/search/5 works fine. But I want to keep the query parameter and read the value.

  • 写回答

1条回答 默认 最新

  • dpmwy80068 2016-11-26 09:46

    That's because of the ? character in the URI. CodeIgniter URI parser (and any other standard URI parser) does not recognize what you have in mind. After the ? character, it's all query string, not URI segments. See the output of PHP's parse_url():

        "path" => "blog/search",
        "query" => "query=post/5",

    See? The first segment is blog, the second is search and the rest is the querystring.

    You need to change your URI design in an standard way. For example:


    So that the call to $this->uri->segment(3) will return what you have in mind.

    Speaking of CodeIgniter pagination library, see reuse_query_string and page_query_string configs in the documentation.

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



  • ¥15 华为ensp使用基本ACL限制公司网络访问
  • ¥15 帮我做下照片上的PLC题
  • ¥15 labview2022 使用modbus报缺少依赖?
  • ¥15 谷歌地图是不是不开通结算功能,api会使用不了哦
  • ¥15 unity腾讯云对象存储机型适配
  • ¥15 求全国交通咨询模拟代码,要求如下,可以完全在dev c++运行
  • ¥15 根据要求修改程序编码
  • ¥15 用 Python 做一个用 Excel 表导入的答题系统
  • ¥15 使用微信开发者工具实现一个“婚博会”小程序
  • ¥15 ros的rviz仿真机器人