Home > Article > Backend Development > How to remove url parameters in php
How to remove url parameters in php
First use the "parse_url()" function to split the url; then reassemble the split data "scheme", "host" and "path" will do.
$rstr=''; $tmparr=parse_url($url); $rstr=empty($tmparr['scheme'])?'http://':$tmparr['scheme'].'://'; $rstr.=$tmparr['host'].$tmparr['path']; return $rstr;
Or use these two functions "strpos()" and "substr()" to delete the parameters after "?".
if ($pos = strpos($url, '?') !== false) { $url = substr($url, $pos, -1); }
The above is the detailed content of How to remove url parameters in php. For more information, please follow other related articles on the PHP Chinese website!