Home > Backend Development > PHP Problem > How to remove url parameters in php

How to remove url parameters in php

Guanhui
Release: 2023-02-28 22:40:02
Original
5500 people have browsed it

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;
Copy after login

Or use these two functions "strpos()" and "substr()" to delete the parameters after "?".

if ($pos = strpos($url, '?') !== false) {
    $url = substr($url, $pos, -1);
}
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template