php判断是pc还是mobile方法
在自己的站点里面引用方法
function is_mobile(){$regExp="/nokia|iphone|ipad|ipod|android|mobile|samsung|sony|htc|motorola|lg|lenovo|blackberry|meizu|oppo|ericsson|huawei|dopod|amoi|gionee|^sie\-|^bird|^zte\-|haier|blazer|netfront|helio|hosin|novarra|techfaith|palmsource|^mot\-|softbank|foma|docomo|kddi|up\.browser|up\.link|symbian|smartphone|midp|wap|phone|windows ce|CoolPad|webos|iemobile|^spice|longcos|pantech|portalmmm|alcatel|ktouch|nexian|^sam\-|s[cg]h|^lge|philips|sagem|wellcom|bunjalloo|maui|jig\s browser|hiptop|ucweb|ucmobile|opera\s*mobi|opera\*mini|mqqbrowser|^benq|^lct480×640|640x480|320x320|240x320|320x240|176x220|220x176/i";if(!isset($_SERVER['HTTP_USER_AGENT'])){return true;}else{return @isset($_SERVER['HTTP_X_WAP_PROFILE'])||@isset($_SERVER['HTTP_PROFILE'])||((isset($_SERVER['HTTP_VIA']))?(stristr($_SERVER['HTTP_VIA'], "wap")?true:false):false)||preg_match($regExp,strtolower($_SERVER['HTTP_USER_AGENT']));}}
$a= (is_mobile())?'mobile':'pc';
if($a=="mobile"){
echo "这是手机访问的网站,可以跳转网址了";
exit;
}else{
echo "这是pc访问的网站,可以跳转至pc的网址";
exit;
}
由力劦工作室提供

浙公网安备 33010602011771号