且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在 PHP 中解析 URL 查询

更新时间:2023-02-23 17:20:56

您可以进行第二步,使用 parse_str.

You can take the second step and parse the query string using parse_str.

$url = 'www.domain.org?x=1&y=2&z=3';
$url_parts = parse_url($url);
parse_str($url_parts['query'], $query_parts);
var_dump($query_parts);

我假设您指的是查询字符串而不是片段,因为片段没有标准模式.

I assumed you meant the query string instead of the fragment because there isn't a standard pattern for fragments.