偵測行動裝置(手機)的 PHP 類別庫

WBOY
發布: 2016-08-08 09:24:43
原創
985 人瀏覽過

Mobile_Detect 是一個輕量級的開源行動裝置(手機)偵測的 PHP Class,它使用 User-Agent 中的字串,並結合 HTTP Header,來偵測行動裝置環境。這個裝置偵測的 PHP 類別庫最強大的地方是,它有一個非常完整的函式庫,可以偵測出所使用的裝置類型(包括操作類型,以及手機品牌等都能偵測)和瀏覽器的詳細資訊。

http://mobiledetect.net/

//使用实例
 
include 'Mobile_Detect.php';
$detect = new Mobile_Detect();
 
// Check for any mobile device.
if ($detect->isMobile())
 
// Check for any tablet.
if($detect->isTablet())
 
// Check for any mobile device, excluding tablets.
if ($detect->isMobile() && !$detect->isTablet())
 
if ($detect->isMobile() && !$detect->isTablet())
 
// Alternative to $detect->isAndroidOS()
$detect->is('AndroidOS');
  
// Batch usage
foreach($userAgents as $userAgent){
  $detect->setUserAgent($userAgent);
  $isMobile = $detect->isMobile();
}
  
// Version check.
$detect->version('iPad'); // 4.3 (float)
登入後複製

來源:http://www.oschina.net/code/snippetreee

來源:http://www.oschina.net/code/snippetreee

以上就介紹了偵測行動裝置(手機)的 PHP 類別庫,包含了方面的內容,希望對PHP教學有興趣的朋友有幫助。 🎜 🎜 🎜
相關標籤:
來源:php.cn
本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板
關於我們 免責聲明 Sitemap
PHP中文網:公益線上PHP培訓,幫助PHP學習者快速成長!