這裡給大家介紹一個行動裝置檢查類了,從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
This is a . Your UA is
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.bKjia.c0m/upload/2013/10/M.rar
http://www.bkjia.com/PHPjc/632784.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/632784.htmlTechArticle這裡給大家介紹一個行動裝置檢查類了,從google找到的mobile-detect類,這個類可以ct判斷android、ios、Tablet平板,瀏覽器,等比較完美完善的判...