zoukankan      html  css  js  c++  java
  • php 判断是用户是pc端还是手机端访问的方法

    function getBrowserType(){
      $is_mobile = false;
      $mobile_os_list=array('Google Wireless Transcoder','Windows CE','WindowsCE','Symbian','Android','armv6l','armv5','Mobile','CentOS','mowser','AvantGo','Opera Mobi','J2ME/MIDP','Smartphone','Go.Web','Palm','iPAQ');
      $mobile_token_list=array('Profile/MIDP','Configuration/CLDC-','160×160','176×220','240×240','240×320','320×240','UP.Browser','UP.Link','SymbianOS','PalmOS','PocketPC','SonyEricsson','Nokia','BlackBerry','Vodafone','BenQ','Novarra-Vision','Iris','NetFront','HTC_','Xda_','SAMSUNG-SGH','Wapaka','DoCoMo','iPhone','iPod');
      $is_mobile = false;
      foreach ($mobile_os_list as $key=>$value) {
        if(strpos($_SERVER['HTTP_USER_AGENT'],$value)){
          $is_mobile = true;
        }
      }
      foreach ($mobile_token_list as $key=>$value) {
        if(strpos($_SERVER['HTTP_USER_AGENT'],$value)){
          $is_mobile = true;
        }
      }
    return $is_mobile;
    }

    如果是手机端,返回true,如果是pc端,返回false,用此代码可以在域名入口处做判断。

  • 相关阅读:
    frog-jump
    nth-digit
    binary-watch
    elimination-game
    evaluate-division
    random-pick-index
    integer-replacement
    rotate-function
    longest-substring-with-at-least-k-repeating-characters
    decode-string
  • 原文地址:https://www.cnblogs.com/ayanboke/p/6609922.html
Copyright © 2011-2022 走看看