<bdo id='4uuwE'></bdo><ul id='4uuwE'></ul>

    1. <small id='4uuwE'></small><noframes id='4uuwE'>

      <tfoot id='4uuwE'></tfoot>
      <legend id='4uuwE'><style id='4uuwE'><dir id='4uuwE'><q id='4uuwE'></q></dir></style></legend>
      <i id='4uuwE'><tr id='4uuwE'><dt id='4uuwE'><q id='4uuwE'><span id='4uuwE'><b id='4uuwE'><form id='4uuwE'><ins id='4uuwE'></ins><ul id='4uuwE'></ul><sub id='4uuwE'></sub></form><legend id='4uuwE'></legend><bdo id='4uuwE'><pre id='4uuwE'><center id='4uuwE'></center></pre></bdo></b><th id='4uuwE'></th></span></q></dt></tr></i><div id='4uuwE'><tfoot id='4uuwE'></tfoot><dl id='4uuwE'><fieldset id='4uuwE'></fieldset></dl></div>

      1. 在分页期间保留 url 参数

        keeping url parameters during pagination(在分页期间保留 url 参数)

          <tbody id='MTkPa'></tbody>

        <tfoot id='MTkPa'></tfoot>

        <small id='MTkPa'></small><noframes id='MTkPa'>

          <i id='MTkPa'><tr id='MTkPa'><dt id='MTkPa'><q id='MTkPa'><span id='MTkPa'><b id='MTkPa'><form id='MTkPa'><ins id='MTkPa'></ins><ul id='MTkPa'></ul><sub id='MTkPa'></sub></form><legend id='MTkPa'></legend><bdo id='MTkPa'><pre id='MTkPa'><center id='MTkPa'></center></pre></bdo></b><th id='MTkPa'></th></span></q></dt></tr></i><div id='MTkPa'><tfoot id='MTkPa'></tfoot><dl id='MTkPa'><fieldset id='MTkPa'></fieldset></dl></div>
        1. <legend id='MTkPa'><style id='MTkPa'><dir id='MTkPa'><q id='MTkPa'></q></dir></style></legend>
          • <bdo id='MTkPa'></bdo><ul id='MTkPa'></ul>
                  本文介绍了在分页期间保留 url 参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  有没有办法在分页时保留我的 GET 参数.

                  Is there any way to keep my GET parameters when paginating.

                  我的问题是我有几个不同的网址,即

                  My problem is that I have a few different urls i.e

                  questions.php?sort=votes&author_id=1&page=3
                  
                  index.php?sort=answers&style=question&page=4
                  

                  如何在我的分页类中创建一个指向页面的链接,该页面上有不同的页码,但仍保留 url 的其他部分?

                  How in my pagination class am I supposed to create a link to the page with a different page number on it but yet still keep the other parts of the url?

                  推荐答案

                  简而言之,您只需解析 URL,然后在末尾添加参数或替换它(如果它已经存在).

                  In short, you just parse the URL and then you add the parameter at the end or replace it if it already exists.

                  $parts = parse_url($url) + array('query' => array());
                  parse_str($parts['query'], $query);
                  $query['page'] = $page;
                  $parts['query'] = http_build_str($query);
                  $newUrl = http_build_url($parts);
                  

                  此示例代码需要 PHP HTTP 模块用于 http_build_urlhttp_build_str.后者可以用 http_build_query 替换,第一个 PHP 用户空间实现存在于如果您没有安装模块.

                  This example code requires the PHP HTTP module for http_build_url and http_build_str. The later can be replaced with http_build_query and for the first one a PHP userspace implementation exists in case you don't have the module installed.

                  另一种选择是使用 Net_URL2 包,它提供了一个各种 URL 操作的接口:

                  Another alternative is to use the Net_URL2 package which offers an interface to diverse URL operations:

                  $op = new Net_URL2($url);
                  $op->setQueryVariable('page', $page);
                  $newUrl = (string) $op;
                  

                  它更加灵活和富有表现力.

                  It's more flexible and expressive.

                  这篇关于在分页期间保留 url 参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  DeepL的翻译效果还是很强大的,如果我们要用php实现DeepL翻译调用,该怎么办呢?以下是代码示例,希望能够帮到需要的朋友。 在这里需要注意,这个DeepL的账户和api申请比较难,不支持中国大陆申请,需要拥有香港或者海外信用卡才行,没账号的话,目前某宝可以
                  PHP通过phpspreadsheet导入Excel日期,导入系统后,全部变为了4开头的几位数字,这是为什么呢?原因很简单,将Excel的时间设置问文本,我们就能看到该日期本来的数值,上图对应的数值为: 要怎么解决呢?进行数据转换就行,这里可以封装方法,或者用第三方的
                  mediatemple - can#39;t send email using codeigniter(mediatemple - 无法使用 codeigniter 发送电子邮件)
                  Laravel Gmail Configuration Error(Laravel Gmail 配置错误)
                  Problem with using PHPMailer for SMTP(将 PHPMailer 用于 SMTP 的问题)
                  Issue on how to setup SMTP using PHPMailer in GoDaddy server(关于如何在 GoDaddy 服务器中使用 PHPMailer 设置 SMTP 的问题)

                  <small id='W7qDR'></small><noframes id='W7qDR'>

                    <i id='W7qDR'><tr id='W7qDR'><dt id='W7qDR'><q id='W7qDR'><span id='W7qDR'><b id='W7qDR'><form id='W7qDR'><ins id='W7qDR'></ins><ul id='W7qDR'></ul><sub id='W7qDR'></sub></form><legend id='W7qDR'></legend><bdo id='W7qDR'><pre id='W7qDR'><center id='W7qDR'></center></pre></bdo></b><th id='W7qDR'></th></span></q></dt></tr></i><div id='W7qDR'><tfoot id='W7qDR'></tfoot><dl id='W7qDR'><fieldset id='W7qDR'></fieldset></dl></div>
                      <bdo id='W7qDR'></bdo><ul id='W7qDR'></ul>

                          <tbody id='W7qDR'></tbody>

                      • <legend id='W7qDR'><style id='W7qDR'><dir id='W7qDR'><q id='W7qDR'></q></dir></style></legend>
                        • <tfoot id='W7qDR'></tfoot>