_php tutorial for detecting Android devices via JavaScript or PHP

Source: Internet
Author: User
With the return of Steve Jobs, IPad2 's release, it seems that the mobile side of the development of the topic more and more hot. Here are some of the top competitors in iOS-android (Android) system detection method.

JavaScript Judgment method

Searching for the Android word in the user agent string is the most provincial way:

 
  
  1. if (Navigator.userAgent.match (/android/i)) {
  2. ' Http://android.davidwalsh.name ' ;

PHP Judgment method

Again, we can use the Strstr method in PHP to search for Android in the user agent:

 
  
  1. if (strstr($_server[' http_user_agent '],' Android ')) {
  2. Header (' location:http://android.davidwalsh.name ');
  3. Exit ();

In addition, it can be judged by. htaccess.

We can use. htaccess to judge and respond to Android devices!

 
  
  1. Rewritecond%{http_user_agent} ^.*android.*$
  2. rewriterule ^ (. *) $ http://android.davidwalsh.name [R=301

This allows you to master all three types of Android device detection methods.

http://article.yeeyan.org/view/56089/176760


http://www.bkjia.com/PHPjc/445839.html www.bkjia.com true http://www.bkjia.com/PHPjc/445839.html techarticle with the return of Steve Jobs, IPad2 's release, it seems that the mobile side of the development of the topic more and more hot. Here are some of the biggest competitors in iOS-android (Android) system to detect the party ...

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