PHP判断客户端为PC还是手机-php教程

资源魔 36 0
本篇文章代码性能是用PHP判别客户端是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_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;
        }
}

相干教程:PHP视频教程

以上就是PHP判别客户端为PC仍是手机的具体内容,更多请存眷资源魔其它相干文章!

标签: php php开发教程 php开发资料 php开发自学 判断客户

抱歉,评论功能暂时关闭!