PHP mobile-detect Check mobile device Access website _php tutorial

Source: Internet
Author: User
Tags php foreach
Here to introduce a mobile device check class, from Google found Mobile-detect class, this class can be computed by CT scan Android, iOS, tablet tablet, browser, and other perfect judgment ipad,iphone,win8, etc.

How to use

The code is as follows Copy Code

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 examples

The code is as follows Copy Code


Require_once ' mobile_detect.php ';
$detect = new Mobile_detect;
$deviceType = ($detect->ismobile ()? ($detect->istablet ()? ' Tablet ': ' Phone '): ' computer ');
$scriptVersion = $detect->getscriptversion ();

?>




<title>Mobile Detect Local Demo</title>




This is a . Your UA is





Supported methods




































































IsMobile (); if ($check):? >class= "true" > Istablet (); if ($check):? >class= "true" > GetRules () as $name + $regex): $check = $detect->{' is '. $name} ();?> Class= "true" > !--? php foreach ($detect->getpro Perties () as $name + $match): $check = $detect->version ($name); if ($check!==false):?> !--? php endif,?-->!--? php Endforeach;?-->
Basic Detection Methods
IsMobile ()
Istablet ()
Custom Detection Methods
is ()
experimental version () method
version (!--? php echo $name;?--) !--? php var_dump ($check); ?-->
Other tests
Isiphone () Isiphone ());?>
Isiphone () Isiphone ());?>
Istablet () Istablet ());?>
Isios () Isios ());?>
Iswhateveryouwant () Iswhateveryouwant ());?>



Php-mobile-detect file download how to: Http://file.bKjia.c0m/upload/2013/10/M.rar

http://www.bkjia.com/PHPjc/632784.html www.bkjia.com true http://www.bkjia.com/PHPjc/632784.html techarticle here to introduce a mobile device check class, from Google to find the Mobile-detect class, this class can be computed by CT scan Android, iOS, tablet tablet, browser, and other relatively perfect sentence ...

  • 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.