您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

如何判断是手机浏览还是电脑浏览

2025/11/23 17:40:02发布14次查看
怎么判断是手机浏览还是电脑浏览
想根据设备的不同而显示不同的页面
判断ip吗???那二者ip段分别是什么~~~
还是判断浏览器类型???这个貌似浏览器太多~~~
------解决方案--------------------
没有绝对的方法能分别。
提供以下函数,如果不是刻意混淆,成功在99%以上~
function ismobile() {
if(isset($_server['http_x_wap_profile'])){
return true;
}
if(isset($_server['http_via']) && stristr($_server['http_via'], wap)){
return true;
}
if(isset($_server['http_user_agent'])){
$clientkeywords = array('nokia', 'sony', 'ericsson', 'mot', 'samsung', 'htc', 'sgh', 'lg', 'sharp', 'sie-',
'philips', 'panasonic', 'alcatel', 'lenovo', 'iphone', 'ipod', 'blackberry', 'meizu', 'android', 'netfront', 'symbian',
'ucweb', 'windowsce', 'palm', 'operamini', 'operamobi', 'openwave', 'nexusone', 'cldc', 'midp', 'wap', 'mobile');
if(preg_match(/( . implode('
------解决方案--------------------
', $clientkeywords) . )/i, strtolower($_server['http_user_agent']))){
return true;
}
}
if(isset($_server['http_accept'])){
if((strpos($_server['http_accept'], 'vnd.wap.wml') !== false)
&& (strpos($_server['http_accept'], 'text/html') === false
------解决方案--------------------
(strpos($_server['http_accept'], 'vnd.wap.wml') < strpos($_server['http_accept'], 'text/html')))){
return true;
}
}
return false;
}
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product