php判断手机客户端
2024-09-08 06:42:45
<?php
// check if wap
function check_wap(){
if(stristr($_SERVER['HTTP_VIA'],"wap")){// 先检查是否为wap代理,准确度高
return true;
}elseif(strpos(strtoupper($_SERVER['HTTP_ACCEPT']),"VND.WAP.WML") > 0){// 检查浏览器是否接受 WML.
return true;
}elseif(preg_match('/(blackberry|configuration\/cldc|hp |hp-|htc |htc_|htc-|iemobile|kindle|midp|mmp|motorola|mobile|nokia|opera mini|opera |Googlebot-Mobile|YahooSeeker\/M1A1-R2D2|android|iphone|ipod|mobi|palm|palmos|pocket|portalmmm|ppc;|smartphone|sonyericsson|sqh|spv|symbian|treo|up.browser|up.link|vodafone|windows ce|xda |xda_)/i', $_SERVER['HTTP_USER_AGENT'])){//检查USER_AGENT
return true;
}else{
return false;
} } if(check_wap()){
echo "手机";
}else{
echo "电脑";
}
最新文章
- java单向加密算法小结(1)--Base64算法
- 回调函数(callback)
- android: SQLite添加数据
- NSURLSession学习笔记
- 【JavsScript】JavaScript MVC框架PK:Angular、Backbone、CanJS与Ember
- 这些年,我收集的JavaScript代码
- Apple Pay强势来袭,开发者应做的事情
- C++ HttpServlet 高并发多线程 HTTP 服务器(转)
- 一周学会Mootools 1.4中文教程:(7)汇总收尾
- ROOT android 原理。 基于(zergRush)
- thinkphp5.1验证器场景验证中传参的方法。
- python实例一
- maven使用utf8等
- 关于PHP中的全局变量global和$GLOBALS的不同区分
- Golang 实现 set 集合,变相实现 切片去重、排序 功能
- 【做题】neerc2017的A、C、I、L
- Linux 下crontab 详解转
- ios开发之--首页 导航栏隐藏 下一级页面显示,pop回来显示白条
- python时间格式化及前推
- java.lang.IllegalStateException: The specified child already has a parent. You must call removeView
热门文章
- 阿里云ECS的使用
- IE11中实现颜色渐变
- [转]nginx启动期都做了哪些事
- 《深入浅出MyBatis技术原理与实战》——7. 插件
- Search Insert Position——二分法
- spring-web涉及jar包说明
- SPOJ - PHRASES K - Relevant Phrases of Annihilation
- 六十 数据库访问 使用SQLAlchemy
- JDBC连接执行mysql存储过程报权限错误:User does not have access to metadata required to determine stored procedure parameter types. If rights can not be granted,
- 初始pip