我有一个包含以下组件的 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/