在javascript中,我对请求参数的某些部分进行如下编码
window.location.href = "search.php?qry=" + encodeURIComponent("m & l");
在我的search.php中,我是这样找到这个的
$url = urldecode($_SERVER['REQUEST_URI']); echo ."Full URL: " .$url ."<br>"; $parts = parse_url($url); parse_str($parts['query'], $query); $qry = "Just Query: " .trim($query['qry']); echo $qry ."<br>";
打印出:
Full Url: /Search.php?qry=m & l Just Query: m
看起来像是 & 正在删除“M&L”`
&
我需要在php或javascript中做什么更改?
$url = urldecode($_SERVER['REQUEST_URI']);
$url = $_SERVER['REQUEST_URI'];
parse_url
$_GET['qry'] 'm & l'
$_GET['qry']
'm & l'
encodeURIComponent
window.location.href = "search.php?qry=" + encodeURIComponent("m & l") + "&subcat="+encodeURIComponent("hello & there");