这里给大家介绍一个移动设备检查类了,从google找到的mobile-detect类,这个类可以ct判断android、ios、Tablet平板,浏览器,等比较完美完善的判断ipad,iPhone,win8等
使用方法
| 代码如下 |
复制代码 |
|
include 'Mobile_Detect.php';
$detect = new Mobile_Detect();
if ($detect->isMobile()) {
// Any mobile device.
}
if($detect->isTablet()){
// Any tablet device.
}
Check for a specific platform:
if($detect->isiOS()){
// Code to run for the Apple's iOS platform.
}
if($detect->isAndroidOS()){
// Code to run for the Google's Android platform.
}
|
官方实例
| 代码如下 |
复制代码 |
|
require_once 'Mobile_Detect.php';
$detect = new Mobile_Detect;
$deviceType = ($detect->isMobile() ? ($detect->isTablet() ? 'tablet' : 'phone') : 'computer');
$scriptVersion = $detect->getScriptVersion();
?>
Mobile Detect Local Demo
营销型企业网站源码响应式界面1.0.1
这几年企业营销型网站成为PC端风靡一时的设计主流,主要特点就是首页长度比较长,首页展示的内容量非常大,通过对首页的大量渲染,突出企业优势、产品服务优势等众多信息,让用户在页面停留时间更久,对企业的映像更加深刻,从而达到营销的目的。但是对于大部分的营销型网站来说,一个最大的弱点就是在手机上的用户体验都比较差,而这又恰好是自适应网站所具备的优势,自适应网站能够自动检测访问者浏览设备的分辨率,从而根据访
下载
This is a . Your UA is
立即学习“PHP免费学习笔记(深入)”;
Supported methods
Basic detection methods |
isMobile() |
isMobile(); if($check): ?>class="true">
|
isTablet() |
isTablet(); if($check): ?>class="true">
|
Custom detection methods |
getRules() as $name => $regex):
$check = $detect->{'is'.$name}();
?>
is() |
class="true">
|
Experimental version() method |
foreach($detect->getProperties() as $name => $match):
$check = $detect->version($name);
if($check!==false):
?>
version() |
|
Other tests |
isiphone() |
isiphone()); ?> |
isIphone() |
isIphone()); ?> |
istablet() |
istablet()); ?> |
isIOS() |
isIOS()); ?> |
isWhateverYouWant() |
isWhateverYouWant()); ?> |
|
php-mobile-detect文件下载地焉: http://file.111cn.net/upload/2013/10/M.rar