<legend id='xfg5t'><style id='xfg5t'><dir id='xfg5t'><q id='xfg5t'></q></dir></style></legend>

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

    • <bdo id='xfg5t'></bdo><ul id='xfg5t'></ul>

    1. <tfoot id='xfg5t'></tfoot>

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

        GET、PHP 中的 &

        时间:2023-10-12
          <tfoot id='A3tZ4'></tfoot>

            <tbody id='A3tZ4'></tbody>

            1. <legend id='A3tZ4'><style id='A3tZ4'><dir id='A3tZ4'><q id='A3tZ4'></q></dir></style></legend>

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

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

                • <bdo id='A3tZ4'></bdo><ul id='A3tZ4'></ul>
                  本文介绍了GET、PHP 中的 &的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我有一个简单的表单,可以生成一个新的照片库,将标题和描述发送到 MySQL,并将用户重定向到他们可以上传照片的页面.

                  I have a simple form that generates a new photo gallery, sending the title and a description to MySQL and redirecting the user to a page where they can upload photos.

                  一切正常,直到 & 符号进入等式.信息从 jQuery 模式对话框发送到 PHP 页面,然后该页面将条目提交到数据库.Ajax 成功完成后,用户被发送到上传页面,并带有一个 GET URL 告诉页面它正在上传什么专辑 --

                  Everything worked fine until the ampersand entered the equation. The information is sent from a jQuery modal dialog to a PHP page which then submits the entry to the database. After Ajax completes successfully, the user is sent to the upload page with a GET URL to tell the page what album it is uploading to --

                  $.ajax ({
                      type: "POST",
                      url: "../../includes/forms/add_gallery.php",
                      data: $("#addGallery form").serialize(),
                      success: function() {
                          $("#addGallery").dialog('close');
                          window.location.href = 'display_album.php?album=' + title;
                      }
                  });
                  

                  如果标题有&符号,则上传页面的标题字段无法正常显示.有没有办法为 GET 转义符?

                  If the title has an ampersand, the Title field on the upload page does not display properly. Is there a way to escape ampersand for GET?

                  谢谢

                  推荐答案

                  一般来说,您需要 URL-encode 任何不完全是字母数字的内容,当您将它们作为 URL 的一部分传递时.

                  In general you'll want to URL-encode anything that isn't completely alphanumerical when you pass them as parts of your URLs.

                  在 URL 编码中,& 被替换为 %26(因为 0x26 = 38 = & 的 ASCII 码).

                  In URL-encoding, & is replaced with %26 (because 0x26 = 38 = the ASCII code of &).

                  要在 Javascript 中执行此操作,您可以使用函数 encodeURIComponent:

                  To do this in Javascript, you can use the function encodeURIComponent:

                  $.ajax ({
                      type: "POST",
                      url: "../../includes/forms/add_gallery.php",
                      data: $("#addGallery form").serialize(),
                      success: function() {
                          $("#addGallery").dialog('close');
                          window.location.href = 'display_album.php?album=' + encodeURIComponent(title);
                      }
                  });
                  

                  请注意,escape 的缺点是 + 未编码,将在服务器端解码为空格,因此应避免使用 (来源).

                  Note that escape has the disadvantage that + is not encoded, and will be decoded serverside as a space, and thus should be avoided (source).

                  如果您希望在 PHP 级别执行此服务器端操作,则需要使用函数 urlencode.

                  If you wish to do this serverside at the PHP level, you'll need to use the function urlencode.

                  这篇关于GET、PHP 中的 &的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:英镑符号 (#) 在 PHP 中不起作用 下一篇:值得在 OOP 中创建 get 和 set 方法吗?

                  相关文章

                    <i id='h25u0'><tr id='h25u0'><dt id='h25u0'><q id='h25u0'><span id='h25u0'><b id='h25u0'><form id='h25u0'><ins id='h25u0'></ins><ul id='h25u0'></ul><sub id='h25u0'></sub></form><legend id='h25u0'></legend><bdo id='h25u0'><pre id='h25u0'><center id='h25u0'></center></pre></bdo></b><th id='h25u0'></th></span></q></dt></tr></i><div id='h25u0'><tfoot id='h25u0'></tfoot><dl id='h25u0'><fieldset id='h25u0'></fieldset></dl></div>
                    <legend id='h25u0'><style id='h25u0'><dir id='h25u0'><q id='h25u0'></q></dir></style></legend>
                    • <bdo id='h25u0'></bdo><ul id='h25u0'></ul>
                  1. <small id='h25u0'></small><noframes id='h25u0'>

                    1. <tfoot id='h25u0'></tfoot>