如何判断是用pc端还是手机端浏览的网页呢?
回复内容: 如何判断是用pc端还是手机端浏览的网页呢?
php 有个手机检测的库很出名啊 mobile-detect
地址:https://packagist.org/packages/mobiledetect/mobiledetectlib
0?$matches[0]:''; function checksubstrs($substrs,$text){ foreach($substrs as $substr){ if(false!==strpos($text,$substr)){ return true; }else{ return false; } } } $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; }}if (ismobile())echo 'phone';elseecho 'pc';?>
详细链接 链接描述
判断ua呗。