php-mobile-detect (Mobile_Detect) 是一個 PHP 類,用來通過 User-Agent 檢測各種手機裝置。
示例代碼:
include("Mobile_Detect.php");
$detect =newMobile_Detect();
if($detect->iOS()){
// code to run for the Apple iOS platform.
}
if($detect->isAndroidOS()){
// code to run for the Google Android platform.
}
if($detect->isMobile()){
// any mobile platform
}
if($detect->isTablet()){
// any tablet
}