在PHP中将'%23'转换为'#'

时间:2012-04-07 23:10:31

标签: php hashtag htmlspecialchars

网址: example.com/search:#searchWord

由于#未发送到服务器,因此会更改为%23

在我想要显示的搜索页面中

结果:#searchWord

但我得到的是%23searchWord。我试过了htmlspecialchars(),但没有任何反应。

2 个答案:

答案 0 :(得分:3)

要实现目标,请使用urldecode

答案 1 :(得分:1)

echo urlencode('example.com/search:#searchWord');
// output: example.com%2Fsearch%3A%23searchWord

echo urldecode('example.com%2Fsearch%3A%23searchWord');
// output: example.com/search:#searchWord