且构网

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

PHP REGEX:从URL获取域

更新时间:2022-04-09 23:15:30

没有必要使用一个正则表达式。 PHP有一个内置函数来做这个。使用 parse_url()

There's no need to use a regex for this. PHP has an inbuilt function to do just this. Use parse_url():

$domain = parse_url($url, PHP_URL_HOST);