碰到的問題是 查詢的時候 填寫這樣的字符串:packageCenter/xxxx?scene=t%3Dp_c67bd3exxxxxxxxx
用 php 的自帶的超全局變量 $_GET
獲取到的是解碼後的的字符串:packageCenter/xxxx?scene=t=p_c67bd3exxxxxxxxx
。
解決方案:使用 $_SERVER['QUERY_STRING']
來獲取未解碼前的查詢字符串。
function getNonDecodedParameters() {
$a = array();
foreach (explode ("&", $_SERVER["QUERY_STRING"]) as $q) {
$p = explode ('=', $q, 2);
$a[$p[0]] = isset ($p[1]) ? $p[1] : '';
}
return $a;
}
$input = getNonDecodedParameters();
$path = isset($input['path']) ? $input['path'] : '';
// $path 變量就是原始查詢字符串(未解碼前的)
參考鏈接: