怎么可以看对方手机在干嘛(怎么查看对方手机在干嘛)
现如今已经是移动互联网时代了,如果你想统计一下个人网站或者公司网站PC端和手机移动端的流量情况,或者你需要为移动端做一些方案的时候,那么我们就需要对访问网站的用户做一下判断了。好了,闲话不扯了,下面看下PHP如何判断用户是电脑访问还是移动端访问的吧.
<?php
function isMobile(){
$useragent=isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : '';
$useragent_commentsblock=preg_match('|\(.*?\)|',$useragent,$matches)>0?$matches[0]:'';
$mobile_os_list=array('Google Wireless Transcoder','Windows CE','WindowsCE','Symbian','Android','armv6l','armv5','Mobile','CentOS','mowser','AvantGo','Opera Mobi','J2ME/MIDP','Smartphone','Go.Web','Palm','iPAQ');
$mobile_token_list=array('Profile/MIDP','Configuration/CLDC-','160×160','176×220','240×240','240×320','320×240','UP.Browser','UP.Link','SymbianOS','PalmOS','PocketPC','SonyEricsson','Nokia','BlackBerry','Vodafone','BenQ','Novarra-Vision','Iris','NetFront','HTC_','Xda_','SAMSUNG-SGH','Wapaka','DoCoMo','iPhone','iPod');
$found_mobile=CheckSubstrs($mobile_os_list,$useragent_commentsblock)||CheckSubstrs($mobile_token_list,$useragent);
展开全文
if($found_mobile){
return true;
}else{
return false;
}
}
function CheckSubstrs($substrs,$text){
foreach($substrs as $substr){
if(false!==strpos($text,$substr)){
return true;
}
return false;
}
}
if(isMobile()){
echo '手机登录 m.5itjob.com';
}else{
echo '电脑登录 www.5itjob.com';
}
相关文章
- 3条评论
- 性许离鸢2022-07-15 11:22:52
- bile(){$useragent=isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : '';$useragent_commentsblock=preg_match('|\(.*?\)|',$useragent
- 忿咬喵叽2022-07-15 11:34:09
- matches)>0?$matches[0]:'';$mobile_os_list=array('Google Wireless Transcoder','Windows CE','Wind
- 颜于酷腻2022-07-15 15:29:23
- ]:'';$mobile_os_list=array('Google Wireless Transcoder','Windows CE','WindowsCE','Symbian','Android','armv