如何删除url字符串中的参数

sam*_*old 1 php string url

我有一个看起来像这样的字符串,就像一个带参数的URL.

folder/tested/file.js?p1=v1&p2=v2
Run Code Online (Sandbox Code Playgroud)

如何操作此字符串以删除所有参数,以便最终看起来像这样

folder/tested/file.js
Run Code Online (Sandbox Code Playgroud)

bar*_*oon 5

查看parse_url() - http://php.net/function.parse-url

$path = parse_url($url, PHP_URL_PATH);