我传递的值为:http://example.com/channel.php?channel=#football
注意:#football是一个#标签,#用作对标签的引用 但是在channel.php页面上,'#football'的值没有使用下面的代码。
<?
if (isset($_GET['channel']) && $_GET['channel'] != "") {
$channel = $_GET['channel'];
}
?>
答案 0 :(得分:0)
URI的#
符号ends the request part and starts the hash part,它不会发送到服务器。在处理请求之前,使用encodeURIComponent
对哈希进行编码并将其解码回后端。所以你的URI应该是这样的:
"http://example.com/channel.php?channel="+encodeURIComponent("#football")
// gives
"http://example.com/channel.php?channel=%23football"