php检测客户端是手机还是电脑
2012-11-14 00:01
423 查看
<div style="margin:150px auto;text-align:center;border:1px dashed #f00;width:240px;padding:25px 5px;"> <?php function is_mobile(){ $regExp="/nokia|iphone|android|samsung|htc|motorola|blackberry|ericsson|huawei|dopod|amoi|gionee|^sie\-|^bird|^zte\-|haier|"; $regExp.="blazer|netfront|helio|hosin|novarra|techfaith|palmsource|^mot\-|softbank|foma|docomo|kddi|up\.browser|up\.link|"; $regExp.="symbian|smartphone|midp|wap|phone|windows ce|CoolPad|webos|iemobile|^spice|longcos|pantech|portalmmm|"; $regExp.="alcatel|ktouch|nexian|^sam\-|s[cg]h|^lge|philips|sagem|wellcom|bunjalloo|maui|"; $regExp.="jig\s browser|hiptop|ucweb|ucmobile|opera\s*mobi|opera\*mini|mqqbrowser|^benq|^lct"; $regExp.="480×640|640x480|320x320|240x320|320x240|176x220|220x176/i"; if(!isset($_SERVER['HTTP_USER_AGENT'])){ return true; }else{ return @$_GET['mobile'] || isset($_SERVER['HTTP_X_WAP_PROFILE']) || isset($_SERVER['HTTP_PROFILE']) || preg_match($regExp, strtolower($_SERVER['HTTP_USER_AGENT'])); } } ?> <input value="<?php echo '您是'.(is_mobile()? '手机' : '电脑').'用户';?>" readonly /><br /> <a href="/" onclick="alert('<?php echo $_SERVER['HTTP_USER_AGENT'].'\r\nIP:'.$_SERVER['REMOTE_ADDR']; ?>');return false;">查看UA信息</a> <a href='http://www.qsyz.net/'>返回首页</a> </div>
转自http://www.qsyz.net/t-3953-1-1.html
相关文章推荐
- php判断客户端是手机还是电脑访问网站代码
- PHP检测终端设备是平板、手机还是电脑
- 用PHP检测用户是用手机(Mobile)还是电脑(PC)访问网站
- PHP判断客户端是手机还是电脑自动调用加载对应的CSS样式
- PHP识别电脑还是手机访问网站
- PHP识别电脑还是手机访问网站
- PHP判断客户端是PCweb端还是移动手机端方法
- php判断当前的访问是手机还是电脑
- php如何判断是手机访问还是电脑访问
- php判断终端是手机还是电脑访问网站代码
- PHP判断是手机访问还是电脑访问
- php判断终端是手机还是电脑访问网站的思路及代码
- PHP识别电脑还是手机访问网站
- PHP检测及判断手机登录用户是安卓或爱疯(iPhone)客户端
- php 中判断请求来自 移动手机端,还是来自电脑 PC 端
- php如何判断用户通过手机wap访问还是电脑直接访问
- PHP识别电脑还是手机访问网站
- 检测客户端是PC,微信还是手机
- php判断客户端是pc还是手机的方法
- php如何判断用户通过手机wap访问还是电脑直接访问