- 浏览: 13630131 次
- 性别:
- 来自: 洛杉矶
文章分类
- 全部博客 (1994)
- Php / Pear / Mysql / Node.js (378)
- Javascript /Jquery / Bootstrap / Web (435)
- Phone / IOS / Objective-C / Swift (137)
- Ubuntu / Mac / Github / Aptana / Nginx / Shell / Linux (335)
- Perl / Koha / Ruby / Markdown (8)
- Java / Jsp (12)
- Python 2 / Wxpython (25)
- Codeigniter / CakePHP (32)
- Div / Css / XML / HTML5 (179)
- WP / Joomla! / Magento / Shopify / Drupal / Moodle / Zimbra (275)
- Apache / VPN / Software (31)
- AS3.0/2.0 / Flex / Flash (45)
- Smarty (6)
- SEO (24)
- Google / Facebook / Pinterest / SNS (80)
- Tools (22)
最新评论
-
1455975567:
xuezhongyu01 写道wocan23 写道我想问下那个 ...
Mysql: LBS实现查找附近的人 (两经纬度之间的距离) -
xuezhongyu01:
wocan23 写道我想问下那个111.1是怎么得来的我也看不 ...
Mysql: LBS实现查找附近的人 (两经纬度之间的距离) -
18335864773:
试试 pageoffice 在线打开 PDF 文件吧. pag ...
jquery在线预览PDF文件,打开PDF文件 -
青春依旧:
opacity: 0.5; 个人喜欢这种方式!关于其他css特 ...
css透明度的设置 (兼容所有浏览器) -
July01:
推荐用StratoIO打印控件,浏览器和系统的兼容性都很好,而 ...
搞定网页打印自动分页问题
1. php mobile detect
<?php /** * Mobile Detect * * @license http://www.opensource.org/licenses/mit-license.php The MIT License * @version SVN: $Id: Mobile_Detect.php 4 2011-05-26 08:04:20Z vic.stanciu@gmail.com $ */ class Mobile_Detect { protected $accept; protected $userAgent; protected $isMobile = false; protected $isAndroid = null; protected $isBlackberry = null; protected $isOpera = null; protected $isPalm = null; protected $isWindows = null; protected $isGeneric = null; protected $devices = array( "android" => "android", "blackberry" => "blackberry", "iphone" => "(iphone|ipod)", "opera" => "opera mini", "palm" => "(avantgo|blazer|elaine|hiptop|palm|plucker|xiino)", "windows" => "windows ce; (iemobile|ppc|smartphone)", "generic" => "(kindle|mobile|mmp|midp|o2|pda|pocket|psp|symbian|smartphone|treo|up.browser|up.link|vodafone|wap)" ); public function __construct() { $this->userAgent = $_SERVER['HTTP_USER_AGENT']; $this->accept = $_SERVER['HTTP_ACCEPT']; if (isset($_SERVER['HTTP_X_WAP_PROFILE'])|| isset($_SERVER['HTTP_PROFILE'])) $this->isMobile = true; elseif (strpos($this->accept,'text/vnd.wap.wml') > 0 || strpos($this->accept,'application/vnd.wap.xhtml+xml') > 0) $this->isMobile = true; else foreach ($this->devices as $device => $regexp) if ($this->isDevice($device)) $this->isMobile = true; } /** * Overloads isAndroid() | isBlackberry() | isOpera() | isPalm() | isWindows() | isGeneric() through isDevice() * * @param string $name * @param array $arguments * @return bool */ public function __call($name, $arguments) { $device = substr($name, 2); if ($name == "is" . ucfirst($device)) return $this->isDevice($device); else trigger_error("Method $name not defined", E_USER_ERROR); } /** * Returns true if any type of mobile device detected, including special ones * @return bool */ public function isMobile() { return $this->isMobile; } protected function isDevice($device) { $var = "is" . ucfirst($device); $return = $this->$var === null ? (bool) preg_match("/" . $this->devices[$device] . "/i", $this->userAgent) : $this->$var; if ($device != 'generic' && $return == true) $this->isGeneric = false; return $return; } }
Description
Mobile_Detect is a simple PHP class for easy detection of the most popular mobile devices platforms: Android, Blackberry, Opera Mini, Palm, Windows Mobile, as well as generic ones.
Usage
Include and instantiate the class:
include("Mobile_Detect.php"); $detect = new Mobile_Detect();
Check for a specific platform:
if ($detect->isAndroid()) { // code to run for the Google Android platform }
Available methods are isAndroid(), isBlackberry(), isOpera(), isPalm(), isWindows(), isGeneric(). Alternatively, if you are only interested in checking to see if the user is using a mobile device, without caring for specific platform:
if ($detect->isMobile()) { // any mobile platform }
来源:http://code.google.com/p/php-mobile-detect/
2. .htaccess
#redirect mobile browsers RewriteCond %{HTTP_USER_AGENT} ^.*iPhone.*$ RewriteRule ^(.*)$ http://mobile.yourdomain.com [R=301] RewriteCond %{HTTP_USER_AGENT} ^.*BlackBerry.*$ RewriteRule ^(.*)$ http://mobile.yourdomain.com [R=301] RewriteCond %{HTTP_USER_AGENT} ^.*Palm.*$ RewriteRule ^(.*)$ http://mobile.yourdomain.com [R=301]
或者
RewriteCond %{REQUEST_URI} !^/mobiledirectoryhere/.*$ RewriteCond %{HTTP_USER_AGENT} "android|blackberry|ipad|iphone|ipod|iemobile|opera mobile|palmos|webos|googlebot-mobile" [NC] RewriteRule ^(.*)$ /mobiledirectoryhere/ [L,R=302]
发表评论
-
手机firebug查看网页代码 How to View Website Source Codes on iPad / iPhone
2016-04-26 02:41 1120You’re using your iPad to br ... -
Android模拟器genymotion的安装和使用
2016-03-18 01:16 2470Genymotion概述 Genymotion是一套完整的 ... -
编码之道:取个好名字很重要
2015-10-14 05:19 1116代码就是程序员的孩子,给“孩子”取个好听的名字很重 ... -
Genymotion - 强大好用高性能的 Android 模拟器 (在电脑流畅运行APK安卓软件游戏的利器)
2015-06-05 13:34 7320随着 Android 系统的应用和游戏越来越丰富,甚至有 ... -
收集几个移动平台浏览器的User-Agent
2014-07-23 02:33 2973List of all Mobile Browsers ... -
常用浏览器修改User-Agent的方法
2014-06-28 02:58 10901之前有介绍收集的几个移动平台浏览器的User-Agent,以 ... -
更简洁的方式修改Chrome的User Agent,轻松体验移动版网络
2014-06-28 02:53 6866国庆节在家宅着,使用3g上网卡上网,和在公司上网不一样的是 ... -
3个检测浏览器User-Agent信息的网站
2014-06-28 02:52 2495刚刚在收集各个移动平台浏览器的User-Agent(参见这 ... -
根据移动设备屏幕像素密度,给予不同分辨率的图片
2014-06-26 00:52 2906在出现iphone4之前的相当长的时间内,网站开发人员 ... -
视网膜New iPad与普通分辨率iPad页面的兼容处理
2014-06-26 00:44 1268一、这是篇经验分享 ... -
iOS8开发-Swift编程
2014-06-25 00:45 1825课时列表 章节1:第一个Swift应用 ... -
Swift中文教程(二十三) 高级运算符
2014-06-25 00:43 780除了基本操作符中所讲的运算符,Swift还有许多复杂的高级 ... -
Swift中文教程(二十二) 泛型
2014-06-25 00:35 1003泛型代码可以让你写出根据自我需求定义、适用于任何类型的,灵 ... -
Swift中文教程(二十一) 协议
2014-06-24 05:25 1004Protocol(协议)用于统一方法和属性的名称,而不实现任 ... -
Swift中文教程(二十) 扩展
2014-06-24 00:47 682扩展就是向一个已有的类、结构体或枚举类型添加新功能(fun ... -
Swift中文教程(十九) 类型嵌套
2014-06-24 00:44 884枚举类型常被用于实现特定类或结构体的功能。也能够在有多种变量 ... -
Swift中文教程(十八) 类型检查
2014-06-24 00:41 721类型检查是一种检查类实例的方式,并且或者也是让实例作为它的 ... -
Swift中文教程(十七) 可选链
2014-06-17 05:11 862可选链(Optional Chaining)是一种可以请求 ... -
Swift中文教程(十六) 自动引用计数
2014-06-17 05:05 1242Swift使用自动引用计数(ARC)来管理应用程序的内存使 ... -
Swift中文教程(十五) 析构
2014-06-17 04:57 995在一个类的实例被释放之前,析构函数会被调用。用关键字dei ...
相关推荐
PHP网站判断用户是否用移动设备访问 内有实例
一个轻量级的PHP类,用于检测移动设备(包括平板)。当用户用移动设备浏览页面时。会自动跳转到相应页面。内部有相应demo
Mobile Detect是一个PHP类,通过User-Agent检测各种手机设备,并结合HTTP Header来检测移动设备环境。该类库最强大的地方是,它有一个非常完整的库,可以检测出所用的设备类型(包括操作类型、以及手机品牌等都能...
include('sstn/mobile_device_detect.php'); mobile_device_detect(false,true,true,'m/index.php',false); 2、上传附件中的mobile_device_detect.php到sstn目录。没有就在根目录新建一个。 说明。代码中的"m...
在PHP中进行移动检测检测客户的设备(移动/平板电脑/ PC)
Mobile Detect是用于检测移动设备(包括平板电脑)的轻量级PHP类。 它结合使用User-Agent字符串和特定的HTTP标头来检测移动环境。 为什么 您网站的内容策略很重要! 您需要一个完整的工具包来提供经过优化,快速且...
安装ipub / mobile-detect的最佳方法是使用 : $ composer require ipub/mobile-detect 之后,您必须在config.neon中注册扩展名。 extensions : mobileDetect : IPub\MobileDetect\DI\MobileDetectExtension ...
用来判断当前登录的浏览器是手机还平板,当前浏览器是ipad还是android等,非常强大
'version' => $detect->getScriptVersion(), // All headers that trigger 'isMobile' to be 'true', // before reaching the User-Agent match detection. 'headerMatch' => $detect->...
主要介绍了PHP检测移动设备类mobile detection使用实例,mobile detection可以检测到绝大部分手机、平板电脑的操作系统、浏览器等数据,需要的朋友可以参考下
Mobile Detect是一个PHP类,通过User-Agent检测各种手机设备,并结合HTTP Header来检测移动设备环境。该类库最强大的地方是,它有一个非常完整的库,可以检测出所用的设备类型(包括操作类型、以及手机品牌等都能...
下载地址http://code.google.com/p/php-mobile-detect/ 程序就是一个文件,下载之后直接引用就...if ($detect->isMobile()) { // any mobile platform echo ‘isMobile’;}else{ echo ‘isPC’;}?> 您可能感兴趣
需要opencart / system / startup.php手动修改: 函数start($ application_config){require_once(DIR_SYSTEM。'framework.php'); } 应该: 函数start($ application_config){require_once(modification(DIR_...
PHP判断访问的设备,移动设备判断,能判断所以移动的设备还是PC端设备,IPhone,IPod,WP,Android,PC,直接引入一个文件就行了。
php开发 登陆后识别是电脑还是手机 include(\ mobile_device_detect.php\ ) mobile_device_detect(true,true,true,true,true,true,"\ http://micjp.dyndns.info\ ",false)
您只需要使用Mage::helper('mobiledetect')->而不是$detect-> 此扩展主要供希望编写PHP条件以检测移动设备的开发人员使用。 常见问题 1.我应该备份Magento的文件和数据库吗? 不需要。 该扩展名不涉及Magento的...
Mobiledetect 是一个用于 CMS Made Simple System 的 Smarty 插件,使用由 Serban Ghita 编写的 Mobile_Detect PHP 类。 有关 Mobile_Detect 类的更多信息,您可以访问 ,如果您觉得缺少某些检测、发现错误或想为 ...
关于Mobile Detect是用于检测移动设备(包括平板电脑)的轻量级PHP类。 它使用User-Agent字符串组合格言:“每个企业都应该具有检测脚本来检测移动阅读器。” 关于Mobile Detect是用于检测移动设备(包括平板电脑)...
composer require hisorange/browser-detect 是的,您可以随时使用它! ^。^ 如何使用 在您的代码中,只需调用浏览器外观: use Browser ; // Determine the user's device type is simple as this: Browser :: ...
介绍该捆绑包使用类,并提供以下功能: 通过名称,操作系统,浏览器用户代理检测各种移动设备管理各种移动设备( mobile设备, tablet , full )的网站视图重定向到手机和平板电脑网站文献资料文档的大部分存储在此...