Home >Backend Development >PHP Tutorial >PHP detects whether the user accesses the website using a mobile phone (Mobile)

PHP detects whether the user accesses the website using a mobile phone (Mobile)

WBOY
WBOYOriginal
2016-07-25 09:13:19946browse

An open source PHP program based on the MIT License: http://code.google.com/p/php-mobile-detect/

The program is just a file, you can just quote it directly after downloading.

How to use:

  1. //Detect whether a mobile phone is accessing the website
  2. include("Mobile_Detect.php");
  3. $detect = new Mobile_Detect();
  4. if ($detect->isMobile()) {
  5. // any mobile platform
  6. echo 'isMobile';
  7. }
  8. else{
  9. echo 'isPC';
  10. } // bbs.it-home.org
  11. ?>
Copy code


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn