• php $_SERVER['HTTP_USER_AGENT'] 2


    //mobile  false pc   true no pc
        function is_mobile(){
            $agent = strtolower($_SERVER['HTTP_USER_AGENT']);
            $is_pc = (strpos($agent, 'windows nt')) ? true : false;
            $is_mac = (strpos($agent, 'mac os')) ? true : false;
            /* $is_linux =    (strpos($agent, 'linux')) ? true : false;
            $is_unix =    (strpos($agent, 'unix')) ? true : false;
             */
            $is_iphone = (strpos($agent, 'iphone')) ? true : false;
            $is_android = (strpos($agent, 'android')) ? true : false;
            $is_ipad = (strpos($agent, 'ipad')) ? true : false;
            

            if($is_pc){
                  return  false;
            }
            
            if($is_mac){
                  return  true;
            }
            
            /* if($is_linux){
                  return  false;
            }
            
            if($is_unix){
                  return  false;
            } */
            
            if($is_iphone){
                  return  true;
            }
            
            if($is_android){
                  return  true;
            }
            
            if($is_ipad){
                  return  true;
            }
        }
        
        function infoAgent(){
            $agent = strtolower($_SERVER['HTTP_USER_AGENT']);
            return $agent;
        }
        
        function is_iphone(){
            $info = false;
            if(strpos(tecrm::infoAgent(), 'iphone')){
                $info = "iphone";
            }
            return $info;
        }
        
        function is_android(){
            $info = false;
            if(strpos(tecrm::infoAgent(), 'android')){
                $info = "android";
            }
            return $info;
        }
        
        function is_ipad(){
            $info = false;
            if(strpos(tecrm::infoAgent(), 'ipad')){
                $info = "ipad";
            }
            return $info;
        }

  • 相关阅读:
    理解 Javascript 执行上下文和执行栈
    CSS中选择器优先级的权重计算
    一年内经验前端面试题记录
    ie8兼容问题
    css文本两端对齐
    前端 SPA 单页应用数据统计解决方案 (ReactJS / VueJS)
    我在SharePoint行业的从业经历(一)
    android中的AlertDialog具体概述
    Android 最火的高速开发框架xUtils
    Project Euler:Problem 93 Arithmetic expressions
  • 原文地址:https://www.cnblogs.com/yuwensong/p/4060480.html
Copyright © 2020-2023  润新知