码迷,mamicode.com
首页 > Web开发 > 详细

检测客户端系统-PHP

时间:2016-05-15 12:21:09      阅读:225      评论:0      收藏:0      [点我收藏+]

标签:

if(isset($_SERVER[‘HTTP_USER_AGENT‘])) {

        $userAgent = strtolower($_SERVER[‘HTTP_USER_AGENT‘]);

        $clientkeywords = array(
            ‘nokia‘, ‘sony‘, ‘ericsson‘, ‘mot‘, ‘samsung‘, ‘htc‘, ‘sgh‘, ‘lg‘, ‘sharp‘, ‘sie-‘
        ,‘philips‘, ‘panasonic‘, ‘alcatel‘, ‘lenovo‘, ‘iphone‘, ‘ipod‘, ‘blackberry‘, ‘meizu‘,
            ‘android‘, ‘netfront‘, ‘symbian‘, ‘ucweb‘, ‘windowsce‘, ‘palm‘, ‘operamini‘,
            ‘operamobi‘, ‘opera mobi‘, ‘openwave‘, ‘nexusone‘, ‘cldc‘, ‘midp‘, ‘wap‘, ‘mobile‘
        );
        $upgradekeywords = array(‘iphone‘,‘ipod‘,‘chrom‘,‘safari‘);
        $operaminikeywords = array(‘operamini‘,‘opera mini‘,‘opera mobi‘);
        $androidkeywords = array(‘android‘);
        echo($userAgent.‘<br/>‘);
//        echo(preg_match("/(".implode(‘|‘,$clientkeywords).")/i",$userAgent));
//        echo(strpos($userAgent,‘ipad‘));
//       // 从HTTP_USER_AGENT中查找手机浏览器的关键字
//        echo(preg_match("/(".implode(‘|‘,$clientkeywords).")/i",$userAgent)&&strpos($userAgent,‘ipad‘));

        if(preg_match("/(".implode(‘|‘,$clientkeywords).")/i",$userAgent)&&strpos($userAgent,‘ipad‘)=== false)
        {
            if(preg_match("/(".implode(‘|‘,$androidkeywords).")/i",$userAgent)){
                header("Location: http://xxxxx");
                exit;
            }else{
                header("Location: http://xxxxx");
                exit;
            }
        }else{
            header("Location: xxxxxx");
            exit;
        }

    }

 

检测客户端系统-PHP

标签:

原文地址:http://www.cnblogs.com/yaohonv/p/5494945.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!