gpt4 book ai didi

javascript - &(与号)符号未出现在 php 页面中的 GET 参数值中

转载 作者:行者123 更新时间:2023-11-28 15:51:36 25 4
gpt4 key购买 nike

我有一个包含以下组件的 php 页面。单击 GET 值应显示在文本框中

JavaScript

category= Biscuits & Creams
document.location.href= "page.php?category="+category;

加载时 GET 参数如下,

page.php?category=Biscuits%20&%20Creams

在php页面中显示该值:

<input type="text" Value="<?php echo urlencode($_GET['category']);?>"/>

文本框中的输出如下

Biscuits instead of Biscuits & Creams

最佳答案

PHP 引擎使用 & 来分隔查询字符串中的参数。 Encode it在 URL 中使用它之前。

关于javascript - &(与号)符号未出现在 php 页面中的 GET 参数值中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20380299/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com