辨别平台
2015-06-25 18:33
197 查看
//获得的信息 $headers = Yii::$app->request->headers; $agent=$headers['user-agent']; /** * 分辨iOS Android 微信 微信分享到浏览器 */ public static function getType($agent){ $ios = explode('iPhone',$agent); $android=explode('Android',$agent); $weixin=explode('MicroMessenger',$agent); //判断为iOS 安卓 type 1为iOS,2为Android,3为微信, $type=0; if(count($ios)>1){ $type=1; }else if(count($android)>1&&empty(Yii::$app->request->get('from'))){ $type=2; }else if(Yii::$app->request->get('from')&&count($weixin)>1){ //在微信中打开 $type=3; }else if(Yii::$app->request->get('from')&&count($weixin)<=1&&count($ios)>1){ //微信中分享到浏览器ios平台 $type=1; }else if(Yii::$app->request->get('from')&&count($weixin)<=1&&count($android)>1){ //微信中分享到浏览器 安卓平台 $type=2; } return $type; }
相关文章推荐
- C++实现Log()日志函数
- 二叉树后序遍历和层次遍历
- ceph运维常用指令
- HTML5游戏实战之70行代码实现经典游戏《伐木工》
- 关于 P2P facebookc 等设计网络技术架构概念汇总
- 查看.Net Framework版本号
- QtQuick桌面应用程序开发指南 4)动态管理Note对象_B 5)加强外观 6)许多其他的改进
- 图形学-名词-番外篇
- Cloudxns使用心得
- css 关于overflow:hidden对float的影响
- IplImage 数据结构
- ScrollView增加标题并且控制显示和隐藏
- 多线程 or 多进程
- 未来技术指南
- Android Volley完全解析(一),初识Volley的基本用法
- 注意HTML的语言编码charset
- Android APK 文件自动安装
- MySQL导入.sql文件及常用命令
- 做网站用UTF-8编码还是GB2312编码?
- 一个linux的提权技巧