Here we will introduce you to a mobile device check class, found from google mobile-detect class, this class can be ct judgment android, ios, Tablet, browser, perfect judgment, such as ipad, iPhone, and win8. Here we will introduce you to a mobile device inspection class, the mobile-detect class found from google, this class can be ct used to determine android, ios, Tablet tablets, browsers, and other perfect judgments, such as ipad, iPhone, and win8.
Script ec (2); script
Usage
The Code is as follows: |
|
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. } |
Official instances
The Code is as follows: |
|
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 . 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 download location: http://file.111cn.net/upload/2013/10/M.rar