通过在到达网址中传递经过修剪的PHP $ _GET来获取哈希

时间:2019-02-13 20:02:25

标签: php

在WAMP本地主机上运行PHP,我正在尝试将$_GET['sku']从一个页面传递到另一个通过URL的页面,例如

<a href="selection.php?sku='<?PHP echo trim($_GET['sku']);?>'" role="button" class="btn to-selection">Add to Selection</a>

此将数据传递到下一页,但我得到了

  

http://localhost:/map/bc/selection.ph?sku=%27MO-1103%27

,而$_GET['sku']MO-1103。为什么在参数前后会出现这些散列?

2 个答案:

答案 0 :(得分:3)

您要在sku ' == %27周围添加'

<a href="selection.php?sku='<?PHP echo trim($_GET['sku']);?>'" role="button" class="btn to-selection">Add to Selection</a>
//       here>>>>>>>>>>>>> ^   and here                >>>> ^

因此将该行更改为

<a href="selection.php?sku=<?PHP echo trim($_GET['sku']);?>" role="button" class="btn to-selection">Add to Selection</a>

答案 1 :(得分:0)

这来自HTML本身。它们是代表无法通过URL发送的实体的代码。 %27表示单引号。

Check this out.