php判断所在的客户端

//判断是否是手机
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_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_iphone){
              return  true;
        }
        
        if($is_android){
              return  true;
        }
        
        if($is_ipad){
              return  true;
        }
}

 

posted @ 2017-12-20 18:05  侠岚之弋痕夕  阅读(359)  评论(0编辑  收藏  举报
Where is the starting point, we don't have a choice, but the destination where we can pursue!