您的位置:首页 > 移动开发

php判断各户端是否为手机端

2017-12-25 14:42 375 查看
[html] view
plain copy

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_iphone){  

              return  true;  

        }  

        if($is_android){  

              return  true;  

        }  

        if($is_ipad){  

              return  true;  

        }  

        if($is_pc){  

              return  false;  

        }   

        if($is_mac){  

              return  false;  

        }  

}  
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: