php获取手机操作系统函数

2634
function getOS(){
$os='';
$Agent=$_SERVER['HTTP_USER_AGENT'];
if (eregi('win',$Agent)&&strpos($Agent, '95')){
$os='Win 95';
}elseif(eregi('win 9x',$Agent)&&strpos($Agent, '4.90')){
$os='Win ME';
}elseif(eregi('win',$Agent)&&ereg('98',$Agent)){
$os='Win 98';
}elseif(eregi('win',$Agent)&&eregi('nt 5.0',$Agent)){
$os='Win 2000';
}elseif(eregi('win',$Agent)&&eregi('nt 6.0',$Agent)){
$os='Win Vista';
}elseif(eregi('win',$Agent)&&eregi('nt 6.1',$Agent)){
$os='Win 7';
}elseif(eregi('win',$Agent)&&eregi('nt 5.1',$Agent)){
$os='Win XP';
}elseif(eregi('win',$Agent)&&eregi('nt 6.2',$Agent)){
$os='Win 8';
}elseif(eregi('win',$Agent)&&eregi('nt 6.3',$Agent)){
$os='Win 8.1';
}elseif(eregi('win',$Agent)&&eregi('nt 10',$Agent)){
$os='Win 10';
}elseif(eregi('win',$Agent)&&eregi('nt',$Agent)){
$os='Win NT';
}elseif(eregi('win',$Agent)&&ereg('32',$Agent)){
$os='Win 32';
}elseif(ereg('Mi',$Agent)){
$os='小米';
}elseif(eregi('Android',$Agent)&&ereg('LG',$Agent)){
$os='LG';
}elseif(eregi('Android',$Agent)&&ereg('M1',$Agent)){
$os='魅族';
}elseif(eregi('Android',$Agent)&&ereg('MX4',$Agent)){
$os='魅族4';
}elseif(eregi('Android',$Agent)&&ereg('M3',$Agent)){
$os='魅族';
}elseif(eregi('Android',$Agent)&&ereg('M4',$Agent)){
$os='魅族';
}elseif(eregi('Android',$Agent)&&ereg('H',$Agent)){
$os='华为';
}elseif(eregi('Android',$Agent)&&ereg('vivo',$Agent)){
$os='Vivo';
}elseif(eregi('Android',$Agent)){
$os='Android';
}elseif(eregi('linux',$Agent)){
$os='Linux';
}elseif(eregi('unix',$Agent)){
$os='Unix';
}elseif(eregi('iPhone',$Agent)){
$os='苹果';
}else if(eregi('sun',$Agent)&&eregi('os',$Agent)){
$os='SunOS';
}elseif(eregi('ibm',$Agent)&&eregi('os',$Agent)){
$os='IBM OS/2';
}elseif(eregi('Mac',$Agent)&&eregi('PC',$Agent)){
$os='Macintosh';
}elseif(eregi('PowerPC',$Agent)){
$os='PowerPC';
}elseif(eregi('AIX',$Agent)){
$os='AIX';
}elseif(eregi('HPUX',$Agent)){
$os='HPUX';
}elseif(eregi('NetBSD',$Agent)){
$os='NetBSD';
}elseif(eregi('BSD',$Agent)){
$os='BSD';
}elseif(ereg('OSF1',$Agent)){
$os='OSF1';
}elseif(ereg('IRIX',$Agent)){
$os='IRIX';
}elseif(eregi('FreeBSD',$Agent)){
$os='FreeBSD';
}elseif($os==''){
$os='Unknown';
}
return $os;
}