获取用户手机设备类型用户画像统计分析-php实用功能记录(五)

阅读559评论0

1abb1572585827.jpg

前面发布了一篇获取用户浏览器的文章《用户画像统计分析之获取用户浏览器-php实用功能记录(四)》,今天继续发布,获取判断访问用户的手机设备类型

包含了大部分市场常用的手机类型

代码如下:

function mobileType($agent){
	if(stripos($agent, "iPhone")!==false){
		$brand = 'iPhone';
	}else if(stripos($agent, "SAMSUNG")!==false || stripos($agent, "Galaxy")!==false || strpos($agent, "GT-")!==false || strpos($agent, "SCH-")!==false || strpos($agent, "SM-")!==false){
		$brand = '三星';
	}else if(stripos($agent, "Huawei")!==false || stripos($agent, "Honor")!==false || stripos($agent, "H60-")!==false || stripos($agent, "H30-")!==false){
		$brand = '华为';
	}else if(stripos($agent, "Lenovo")!==false){
		$brand = '联想';
	}else if(strpos($agent, "MI-ONE")!==false || strpos($agent, "MI 1S")!==false || strpos($agent, "MI 2")!==false || strpos($agent, "MI 3")!==false || strpos($agent, "MI 4")!==false || strpos($agent, "MI-4")!==false){
		$brand = '小米';
	}else if(strpos($agent, "HM NOTE")!==false || strpos($agent, "HM201")!==false){
		$brand = '红米';
	}else if(stripos($agent, "Coolpad")!==false || strpos($agent, "8190Q")!==false || strpos($agent, "5910")!==false){
		$brand = '酷派';
	}else if(stripos($agent, "ZTE")!==false || stripos($agent, "X9180")!==false || stripos($agent, "N9180")!==false || stripos($agent, "U9180")!==false){
		$brand = '中兴';
	}else if(stripos($agent, "OPPO")!==false || strpos($agent, "X9007")!==false || strpos($agent, "X907")!==false || strpos($agent, "X909")!==false || strpos($agent, "R831S")!==false || strpos($agent, "R827T")!==false || strpos($agent, "R821T")!==false || strpos($agent, "R811")!==false || strpos($agent, "R2017")!==false){
		$brand = 'OPPO';
	}else if(strpos($agent, "HTC")!==false || stripos($agent, "Desire")!==false){
		$brand = 'HTC';
	}else if(stripos($agent, "vivo")!==false){
		$brand = 'vivo';
	}else if(stripos($agent, "K-Touch")!==false){
		$brand = '天语';
	}else if(stripos($agent, "Nubia")!==false || stripos($agent, "NX50")!==false || stripos($agent, "NX40")!==false){
		$brand = '努比亚';
	}else if(strpos($agent, "M045")!==false || strpos($agent, "M032")!==false || strpos($agent, "M355")!==false){
		$brand = '魅族';
	}else if(stripos($agent, "DOOV")!==false){
		$brand = '朵唯';
	}else if(stripos($agent, "GFIVE")!==false){
		$brand = '基伍';
	}else if(stripos($agent, "Gionee")!==false || strpos($agent, "GN")!==false){
		$brand = '金立';
	}else if(stripos($agent, "HS-U")!==false || stripos($agent, "HS-E")!==false){
		$brand = '海信';
	}else if(stripos($agent, "Nokia")!==false){
		$brand = '诺基亚';
	}else{
		$brand = '其他手机';
	}
	return $brand;
}

$agent参数是用户的UA,也就是$_SERVER['HTTP_USER_AGENT']


附加ISP运营商对应关系表

    CHINANET:中国电信

    UNICOM:中国联通

    CMNET:中国移动

    CRTC:铁通

    COLNET:有线通

    CERNET:教育网

    CNCGROUP:网通


UA的其他使用:

用户画像统计分析之获取用户浏览器-php实用功能记录(四)

用户画像统计分析之获取访问用户的操作系统-php实用功能记录(六)


0 位网友评论:

欢迎来评论

请填写验证码