[PHP] How to use Mobile_detect to determine which device to visit a website: Android, tablet, PC _php tutorial

Source: Internet
Author: User
Mobile_detect is a lightweight, open source mobile device (mobile) detection PHP Class,

It uses the string in User-agent and combines the HTTP Header to detect the mobile device environment.

The most powerful part of the PHP class library that this device detects is that it has a very complete library,

You can detect the type of device you are using (including the type of operation, as well as the ability to detect your phone's brand, etc.) and the browser's details.

The complete Mobile_detect code is as follows:

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 Usageforeach ($userAgents as $userAgent) {  $detect->setuseragent ($userAgent);  $isMobile = $detect->ismobile ();} Version check. $detect->version (' IPad '); 4.3 (float)

http://www.bkjia.com/PHPjc/477164.html www.bkjia.com true http://www.bkjia.com/PHPjc/477164.html techarticle Mobile_detect is a lightweight, open source mobile device (mobile phone) detection PHP Class that uses strings in User-agent and combines HTTP headers to detect the mobile environment. ...

  • Related Article

    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.