HOME
DOMAIN
WEB HOST
AUTO Site
VPS SERVER
CLOUD HOST
SERVER
HK HOST
AGENT
SERVICE
function matchdomain($q){ preg_match('/(([a-z0-9](w|-){0,61}?[a-z0-9]|[a-z0-9]).){1,}(aero|arpa|asia|biz|cat|com|coop|co|edu|gov|info|int|jobs|mil|mobi|museum|name|net|org|pro|tel|travel|[a-z][a-z])(.[a-z][a-z]){0,1}/', $q, $matches); return $matches[0]; } //实例应用,代码如下: $com = 'www.phpfensi.com'; echo matchdomain($com); //www.phpfensi.com $cn = 'afdsafs'; echo matchdomain($cn); //notice: undefined offset: 0 因为没有不是域名所以正则不到域名所以出错了。