在php中去掉url中的某个参数,的函数如下:
function removeqsvar($url, $var_names) { foreach($var_names as $param){ $url = preg_replace('/([?&])'.$param.'=[^&]+(&|$)/','$1',$url); } $url = trim($url,"?"); $url = trim($url,"#"); $url = trim($url,"&"); $url = trim($url,"/"); return $url; }