AI摘要
本文介绍了如何使用PHP的parse_url函数从网址URL中提取域名。示例代码展示了将网址'https://blog.xiaoxinbk.cn/archives/23/'作为输入,通过parse_url函数解析后,获取并输出域名'blog.xiaoxinbk.cn'的过程。
PHP利用parse_url函数从网址里面获取出域名
$url='https://blog.xiaoxinbk.cn/archives/23/';
$host=parse_url($url);
$host=$host['host'];
echo $host; //输出结果:blog.xiaoxinbk.cn