网站地图    收藏   

主页 > 后端 > php资料库 >

php判断操作系统或浏览器实现代码_自学php网

来源:自学PHP网    时间:2014-12-04 22:12 作者: 阅读:

[导读] function userOS($user_OSagent=){ if(strpos($user_OSagent,NT 6.1)) { $visitor_os = Windows7; }elseif(preg_match(/NT 5.1/,$user_OSagent)){ $visitor_os = Windows XP (SP2); }elseif(strpos($user_OSagent,Windows XP)) { $visitor_os = Windows XP; }e...

function userOS($user_OSagent=”){
if(strpos($user_OSagent,”NT 6.1″)) {
$visitor_os = “Windows7″;
}elseif(preg_match(‘/NT 5.1/’,$user_OSagent)){
$visitor_os = “Windows XP (SP2)”;
}elseif(strpos($user_OSagent,”Windows XP”)) {
$visitor_os = “Windows XP”;
}elseif(strpos($user_OSagent,”NT 5.2″) && strpos($user_OSagent,”WOW64″)){
$visitor_os = “Windows XP 64-bit Edition”;
}elseif(strpos($user_OSagent,”NT 5.2″)) {
$visitor_os = “Windows 2003″;
}elseif(strpos($user_OSagent,”NT 6.0″)) {
$visitor_os = “Windows Vista”;
}elseif(strpos($user_OSagent,”NT 5.0″)) {
$visitor_os = “Windows 2000″;
}elseif(strpos($user_OSagent,”4.9″)) {
$visitor_os = “Windows ME”;
}elseif(strpos($user_OSagent,”NT 4″)) {
$visitor_os = “Windows NT 4.0″;
}elseif(strpos($user_OSagent,”98″)) {
$visitor_os = “Windows 98″;
}elseif(strpos($user_OSagent,”95″)) {
$visitor_os = “Windows 95″;
}elseif(strpos($user_OSagent,”NT 9.0″)) {
$visitor_os = “Windows NT 9.0″;
}elseif(strpos($user_OSagent,”Mac”)) {
$visitor_os = “Mac”;
}elseif(strpos($user_OSagent,”Linux”)) {
$visitor_os = “Linux”;
}elseif(strpos($user_OSagent,”Unix”)) {
$visitor_os = “Unix”;
}elseif(strpos($user_OSagent,”FreeBSD”)) {
$visitor_os = “FreeBSD”;
}elseif(strpos($user_OSagent,”SunOS”)) {
$visitor_os = “SunOS”;
}elseif(strpos($user_OSagent,”BeOS”)) {
$visitor_os = “BeOS”;
}elseif(strpos($user_OSagent,”OS/2″)) {
$visitor_os = “OS/2″;
}elseif(strpos($user_OSagent,”PC”)) {
$visitor_os = “Macintosh”;
}elseif(strpos($user_OSagent,”AIX”)) {
$visitor_os = “AIX”;
}elseif(strpos($user_OSagent,”IBM OS/2″)) {
$visitor_os = “IBM OS/2″;
}elseif(strpos($user_OSagent,”BSD”)) {
$visitor_os = “BSD”;
}elseif(strpos($user_OSagent,”NetBSD”)) {
$visitor_os = “NetBSD”;
}elseif(preg_match(‘/Apple/i’,$user_OSagent)) {
$visitor_os = “Applepc”;
}elseif(strpos($user_OSagent,”NT 6.1″)) {
$visitor_os = “Windows7″;
}elseif(preg_match(‘/Opera/i’,$user_OSagent)) {
$visitor_os = “Opera”;
}elseif(preg_match(‘/Nokia/i’, $user_OSagent)) {
$visitor_os = “nokia”;
}elseif(preg_match(‘/OPPO/i’, $user_OSagent)) {
$visitor_os = “OPPO “;
}elseif(preg_match(‘/SymbianOS/i’, $user_OSagent)) {
$visitor_os = “SymbianOS “;
}elseif(preg_match(‘/Windows Mobile/i’, $user_OSagent)) {
$visitor_os = “Windows Mobile”;
}elseif(preg_match(‘/DoCoMo/i’,$user_OSagent)){
$visitor_os = “DoCoMo”;
}elseif(strpos($user_OSagent,”Red Hat”)) {
$visitor_os = “linux”;
}elseif(preg_match(‘/SonyEricsson/i’,$user_OSagent)) {
$visitor_os = “SonyEricsson”;
}elseif(preg_match(‘/Lynx/i’,$user_OSagent)) {
$visitor_os = “Lynx”;
}elseif(preg_match(‘/ucweb|MQQBrowser|J2ME|IUC|3GW100|LG-MMS|i60|Motorola|MAUI|m9|ME860|maui|C8500|gt|k-touch|X8|htc|GT-S5660|UNTRUSTED|SCH|tianyu|lenovo|SAMSUNG/i’,$user_OSagent)) {
$visitor_os = “mobile”;
}else{
$visitor_os =$user_OSagent;
}
return $visitor_os;
}

function userBrowser($user_OSagent){
if(strpos($user_OSagent,”Maxthon”) && strpos($user_OSagent,”MSIE”)) {
$visitor_browser =”Maxthon(Microsoft IE)”;
}elseif(strpos($user_OSagent,”Maxthon 2.0″)) {
$visitor_browser =”Maxthon 2.0″;
}elseif(strpos($user_OSagent,”Maxthon”)) {
$visitor_browser =”Maxthon”;
}elseif(strpos($user_OSagent,”MSIE 7.0″)) {
$visitor_browser =”IE7″;
}elseif(strpos($user_OSagent,”MSIE 6.0″)) {
$visitor_browser =”IE6″;
}elseif(strpos($user_OSagent,”MSIE 5.5″)) {
$visitor_browser =”IE5″;
}elseif(strpos($user_OSagent,”MSIE 5.0″)) {
$visitor_browser =”IE5″;
}elseif(strpos($user_OSagent,”MSIE 4.01″)) {
$visitor_browser =”IE4″;
}elseif(strpos($user_OSagent,”MSIE 8.0″)) {
$visitor_browser =”IE8″;
}elseif(strpos($user_OSagent,”MSIE 9.0″)) {
$visitor_browser =”IE9″;
}elseif(strpos($user_OSagent,”NetCaptor”)) {
$visitor_browser =”NetCaptor”;
}elseif(strpos($user_OSagent,”Netscape”)) {
$visitor_browser =”Netscape”;
}elseif(strpos($user_OSagent,”Lynx”)) {
$visitor_browser =”Lynx”;
}elseif(strpos($user_OSagent,”Opera”)) {
$visitor_browser =”Opera”;
}elseif(strpos($user_OSagent,”Konqueror”)) {
$visitor_browser =”Konqueror”;
}elseif(strpos($user_OSagent,”Mozilla/5.0″)) {
$visitor_browser =”Mozilla”;
}elseif(preg_match(‘/ucweb/i’, $user_OSagent)) {
$visitor_browser =”ucweb”;
}elseif(preg_match(‘/Opera/i’, $user_OSagent)) {
$visitor_browser =”Opera”;
}elseif(preg_match(‘/SonyEricsson/i’, $user_OSagent)) {
$visitor_browser =”SonyEricsson”;
}elseif(preg_match(‘/Apple/i’,$user_OSagent)) {
$visitor_browser =”Apple”;
}elseif(preg_match(‘/OPPO/i’,$user_OSagent)) {
$visitor_browser =”OPPO”;
}elseif(strpos($user_OSagent,”i60″)) {
$visitor_browser =”lenovo i60″;
}elseif(preg_match(‘/Nokia/i’, $user_OSagent)) {
$visitor_browser =”nokia”;
}elseif(strpos($user_OSagent,”LG-MMS”)) {
$visitor_browser =”LG-BROWSER”;
}elseif(strpos($user_OSagent,”SMIT-BROWSER”)) {
$visitor_browser =”SMIT-BROWSER”;
}elseif(preg_match(‘/zet/i’, $user_OSagent)) {
$visitor_browser =’ZET-BROWSER’;
}elseif(preg_match(‘/Lynx/i’, $user_OSagent)) {
$visitor_browser =’Lynx’;
}elseif(strpos($user_OSagent,”Firefox”)) {
$visitor_browser =”Firefox”;
}elseif(strpos($user_OSagent,”U”)) {
$visitor_browser =”Firefox”;
}else {
$visitor_browser =”$user_OSagent”;
}
return $visitor_browser;
}

 

自学PHP网专注网站建设学习,PHP程序学习,平面设计学习,以及操作系统学习

京ICP备14009008号-1@版权所有www.zixuephp.com

网站声明:本站所有视频,教程都由网友上传,站长收集和分享给大家学习使用,如由牵扯版权问题请联系站长邮箱904561283@qq.com

添加评论