PHP 删除 url 中的 query string
function removeQueryStringFromUrl($url) { if (substr($url,0,4) =="http") { $urlPartsArray = parse_url($url); $outputUrl = $urlPartsArray['scheme']. '://'. $urlPartsArray['host']. ( isset($urlPartsArray['path'])? $urlPartsArray['path'] : '' ); }
else { $URLexploded = explode("?", $url, 2); $outputUrl = $URLexploded[0]; } return $outputUrl; }
测试链接: