检查下面$_SERVER['HTTP_USER_AGENT']列出的一些字符串:
或者更具体地说是爬虫:
如果您想 - 记录大多数常见搜索引擎抓取工具的访问次数,您可以使用$interestingCrawlers=array('google','yahoo');$pattern='/('.implode('|',$interestingCrawlers).')/';$matches=array();$numMatches=preg_match($pattern,strtolower($_SERVER['HTTP_USER_AGENT']),$matches,'i');if($numMatches>0)//Foundamatch{
//$matches[1]containsanarrayofalltextmatchestoeither'google'or'yahoo'}