PHPMobile-Detect: Check mobile device access website-PHP source code

Source: Internet
Author: User
Tags php foreach
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

































































GetRules () as $ name => $ regex ):$ Check = $ detect-> {'is '. $ name }();?> Foreach ($ detect-> getProperties () as $ name => $ match ):$ Check = $ detect-> version ($ name );If ($ check! = False ):?>
Basic detection methods
IsMobile () IsMobile (); if ($ check):?> Class = "true" >
IsTablet () IsTablet (); if ($ check):?> Class = "true" >
Custom detection methods
Is () Class = "true" >
Experimental version () method
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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.