当前位置:Gxlcms > PHP教程 > php检测用户是否用手机(Mobile)访问网站

php检测用户是否用手机(Mobile)访问网站

时间:2021-07-01 10:21:17 帮助过:4人阅读

一个基于MIT License协议开源的PHP程序: http://code.google.com/p/php-mobile-detect/

程序就是一个文件,下载之后直接引用就可以。

使用方法:

  1. //检测是否手机访问网站
  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. ?>

人气教程排行