php URL各部分获取方法(全局变量)
程序员文章站
2022-06-10 19:12:02
...
输出: Array ( [scheme] => http [host] => www.electrictoolbox.com [path] => /php-extract-domain-from-full-url/ ) 示例2:
输出: Array ( [scheme] => http [host] => hostname [user] => username [pass] => password [path] => /path [query] => arg=value [fragment] => anchor ) 很容易便分解出一个URL的各个部,取指定的部分出来也很容易: echo parse_url($url, PHP_URL_PATH); 在第二个参数中,设定如下的参数: PHP_URL_SCHEME, PHP_URL_HOST, PHP_URL_PORT, PHP_URL_USER, PHP_URL_PASS, PHP_URL_PATH, PHP_URL_QUERY or PHP_URL_FRAGMENT。 |