PHP判断当前页面是电脑登录,还是手机登录
2013-11-29 14:19
731 查看
//判断是否是电脑登录,还是手机登录 public function isMobil() { $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 = $this->CheckSubstrs($mobile_os_list, $useragent_commentsblock) || $this->CheckSubstrs($mobile_token_list, $useragent); if ($found_mobile) { echo '手机登录'; } else { echo '电脑登录'; } }
相关文章推荐
- php使用session_destroy()显示警告的解决办法
- 使用PHP静态变量当缓存的方法
- phpcmsv9黄页系统企业库分类问题
- ZF2 Session简单使用(Zend\Authentication\Storage\Session.php)
- 深思 PHP 数组遍历的差异(array_diff 的实现)
- PHP EOF(heredoc)的使用方法
- php中自定义函数dump查看数组信息
- ubuntu上用vsftpd建立匿名ftp服务器
- Yii学习(5)----一些实用技巧
- windows2008利用serv-u14.0.0.6架设FTP服务器的方法
- windows2008利用serv-u14.0.0.6架设FTP服务器的方法
- PHP类的静态方法和静态变量 双冒号::是什么意思
- java 到 php入门:php字符串常用的内置函数
- 解决织梦 \include\userlogin.class.php on line 21 报错的方法
- PHP 下 CURL 通过 POST 提交表单失败的原因及解决方法
- Yii常用技巧总结
- php class中public,private,protected的区别,以及实例
- PHP abstract 和 interface的区别
- 在Apache+php中使用json来通讯
- PHP如何获取当前日期前30天的具体日期