首页 > Web开发 > 详细

php $_SERVER['HTTP_USER_AGENT'] 2

时间:2014-10-29 21:15:09      阅读:291      评论:0      收藏:0      [点我收藏+]

//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;
    }

php $_SERVER['HTTP_USER_AGENT'] 2

原文:http://www.cnblogs.com/yuwensong/p/4060480.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!