//判断是否属手机
function is_mobile() {
$user_agent = $_SERVER['HTTP_USER_AGENT'];
$mobile_agents = Array("240x320","acer","acoon","acs-","abacho","ahong","airness","alcatel","amoi","android","anywhereyougo.com","applewebkit/525","applewebkit/532","asus","audio","au-mic","avantogo","becker","benq","bilbo","bird","blackberry","blazer","bleu","cdm-","compal","coolpad","danger","dbtel","dopod","elaine","eric","etouch","fly ","fly_","fly-","go.web","goodaccess","gradiente","grundig","haier","hedy","hitachi","htc","huawei","hutchison","inno","ipad","ipaq","ipod","jbrowser","kddi","kgt","kwc","lenovo","lg ","lg2","lg3","lg4","lg5","lg7","lg8","lg9","lg-","lge-","lge9","longcos","maemo","mercator","meridian","micromax","midp","mini","mitsu","mmm","mmp","mobi","mot-","moto","nec-","netfront","newgen","nexian","nf-browser","nintendo","nitro","nokia","nook","novarra","obigo","palm","panasonic","pantech","philips","phone","pg-","playstation","pocket","pt-","qc-","qtek","rover","sagem","sama","samu","sanyo","samsung","sch-","scooter","sec-","sendo","sgh-","sharp","siemens","sie-","softbank","sony","spice","sprint","spv","symbian","tablet","talkabout","tcl-","teleca","telit","tianyu","tim-","toshiba","tsm","up.browser","utec","utstar","verykool","virgin","vk-","voda","voxtel","vx","wap","wellco","wig browser","wii","windows ce","wireless","xda","xde","zte");
$is_mobile = false;
foreach ($mobile_agents as $device) {
if (stristr($user_agent, $device)) {
$is_mobile = true;
break;
}
}
return $is_mobile;
}
if( is_mobile() ){
Your Code
}

php 判断是否 是手机访问的更多相关文章

  1. js判断是否为手机访问

    JavaScript判断浏览器类型一般有两种办法,一种是根据各种浏览器独有的属性来分辨,另一种是通过分析浏览器的userAgent属性来判断的.在许多情况下,值判断出浏览器类型之后,还需判断浏览器版本 ...

  2. onethink判断是否是手机访问?

    第一步:找到:Application / Common / Common / function.php 添加判断是否是手机访问的代码: /** * 判断当前访问的用户是 PC端 还是 手机端 返回tr ...

  3. PHP CodeBase: 判断用户是否手机访问(转)

    随着移动设备的普及,网站也会迎来越来越多移动设备的访问.用适应PC的页面,很多时候对手机用户不友好,那么有些时候,我们需要判断用户是否用手机访问,如果是手机的话,就跳转到指定的手机友好页面.这里就介绍 ...

  4. C#判断用户是手机访问还是PC访问

    今天在做一个wap网站时,需要限制PC用户访问.网上找了很多资料,效果都不怎么理想.其实原理就是根据HTTP_USER_AGENT判断检查用户在用什么浏览器,再根据业务做相应的逻辑处理. 代码如下: ...

  5. PHP CodeBase: 判断用户是否手机访问

    随着移动设备的普及,网站也会迎来越来越多移动设备的访问.用适应PC的页面,很多时候对手机用户不友好,那么有些时候,我们需要判断用户是否用手机访问,如果是手机的话,就跳转到指定的手机友好页面.这里就介绍 ...

  6. PHP判断用户是否手机访问

    自定义的函数如下: $agent = check_wap(); if( $agent ) { header('Location: http://www.nowamagic.net'); exit; } ...

  7. php判断是否使用手机访问

    直接上代码 /** * 检测是否使用手机访问 * @access public * @return bool */ public function isMobile() { if (isset($_S ...

  8. js简化判断是否为手机访问

    var ua = navigator.userAgent; var ipad = ua.match(/(iPad).*OS\s([\d_]+)/), isIphone = !ipad &&am ...

  9. PHP 判断用户是否手机访问

    $agent = check_wap(); if( $agent ) { header('Location: http://www.lewanau.com'); exit; } // check if ...

随机推荐

  1. maven核心概念4

    一.Maven坐标 1.1.什么是坐标? 在平面几何中坐标(x,y)可以标识平面中唯一的一点. 1.2.Maven坐标主要组成 groupId:组织标识(包名) artifactId:项目名称 ver ...

  2. JavaWeb学习总结(六)—HttpServletResponse

    Response概述: response是Servlet.service方法的一个参数,类型为javax.servlet.http.HttpServletResponse.在客户端发出每个请求时,服务 ...

  3. spring+redis实现缓存

    spring + redis 实现数据的缓存 1.实现目标 通过redis缓存数据.(目的不是加快查询的速度,而是减少数据库的负担) 2.所需jar包 注意:jdies和commons-pool两个j ...

  4. gdb 调试学习

    gdb 是unix/linux 系统下的程序调试工具,和IDE(如VS, Eclipse等)的图形化调试工具相比,gdb在断点,跟踪显示方面有着不足,但是它在某些方面比图形化调试工具更加丰富的功能. ...

  5. iOS开发 判断字符串是不是网址

    - (BOOL)isUrlString { NSString *emailRegex = @"[a-zA-z]+://.*"; NSPredicate *emailTest = [ ...

  6. mysql数据库回滚

    在应用$mysqli时,因没常用到数据回滚,老忘,整理下,做个记录. $mysqli->autocommit(FALSE);//自动提交设置关闭 $mysqli->query(" ...

  7. 机器学习与R语言

    此书网上有英文电子版:Machine Learning with R - Second Edition [eBook].pdf(附带源码) 评价本书:入门级的好书,介绍了多种机器学习方法,全部用R相关 ...

  8. AHCI驱动安装

    目录 第1章 Windows XP    1 1.1 更新驱动    1 第2章 Windows 7    7 2.1 修改注册表    7 2.2 更新驱动    7 第1章 Windows XP ...

  9. 【转】 Linux chmod命令

    在Unix和Linux的各种操作系统下,每个文件(文件夹也被看作是文件)都按读.写.运行设定权限.例如我用ls -l命令列文件表时,得到如下输出:-rw-r--r-- 1 apple users 22 ...

  10. 理论与实践中的 C# 内存模型,第 2 部分

    转载自:https://msdn.microsoft.com/zh-cn/magazine/jj883956.aspx 这是介绍 C# 内存模型的系列文章的第二篇(共两篇). 正如在 MSDN 杂志十 ...