本文实例讲述了PHP自定义函数获取URL中一级域名的方法。分享给大家供大家参考,具体如下: <?php /* * Created on 2016-8-23 */ function regular_domain($domain) { if (substr ( $domain, 0, 7 ) == 'http://') { $domain = substr ( $domain, 7 ); } if (strpos ( $domain, '/' ) !== false) { $domain = substr ( $domain, 0, strpos ( $do