且构网

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

如何解析PHP中的URL?

更新时间:2022-04-02 22:39:18

您可以使用 parse_url 下来到主机名.

You can use parse_url to get down to the hostname.

例如:

$url = "http://localhost/path/to/?here=there";
$data = parse_url($url);
var_dump($data);

/*
Array
(
    [scheme] => http
    [host] => localhost
    [path] => /path/to/
    [query] => here=there
)
*/