Home >Backend Development >PHP Tutorial >php Get user browser version code_PHP tutorial

php Get user browser version code_PHP tutorial

WBOY
WBOYOriginal
2016-07-20 11:08:13917browse

php gets the user browser version code. In php, we have a global variable $_SERVER['HTTP_USER_AGENT']; which can get all the user's information. We need to process it to determine what type of user's browser it is. The following function can be used The exact user browser version number code.

php tutorial to get the user browser version code
In php we have a global variable $_server['http_user_agent']; which can get all the user's information. We need to process it to determine what type of user browser it is. Yes, the following function can accurately determine the user browser version number code.

function getbrowse()
                                                                                           $browserver = '';
                                    browser = array('lynx', 'mosaic', 'aol', 'opera', 'java', 'macweb', 'webexplorer', 'omniweb');
for($i = 0; $i < ;= 7; $i ++){
                                                                                                        ​                                    $browserver = '' ;
}
}
if(ereg('mozilla', $agent) && !ereg('msie', $agent)){
                  $temp = explode('(', $agent );
$part = $temp[0];
$temp = explode('/', $part);
$browserver = $temp[1];
                                                ' ', $browserver);
$browserver = $temp[0];
$browserver = preg_replace('/([d.]+)/', '1', $browserver);
$browserver = $browserver;
$browser = 'netscape navigator';
}
if(ereg('mozilla', $agent) && ereg('opera', $agent)) {
$temp = explode('(', $agent);
$part = $temp[1];
$temp = explode(')', $part);
$browserver = $temp[ 1];
                        $temp = explode(' ', $browserver);
                        $browserver = $temp[2];
                        $browserver = preg_replace('/([d.]+)/', '1', $browserver);
                        $browserver = $browserver;
                        $browser = 'opera';
                }
                if(ereg('mozilla', $agent) && ereg('msie', $agent)){
                        $temp = explode('(', $agent);
                        $part = $temp[1];
                        $temp = explode(';', $part);
                        $part = $temp[1];
                        $temp = explode(' ', $part);
                        $browserver = $temp[2];
                        $browserver = preg_replace('/([d.]+)/','1',$browserver);
                        $browserver = $browserver;
                        $browser = 'internet explorer';
                }
                if($browser != ''){
                        $browseinfo = $browser.' '.$browserver;
                } else {
                        $browseinfo = false;
                }
                return $browseinfo;
        }
 //应用方法
 
 //在ie中
 echo getbrowse(); //internet explorer 6.0
 //在firefox中
 echo getbrowse() ;//netscape navigator 5.0


www.bkjia.comtruehttp://www.bkjia.com/PHPjc/444900.htmlTechArticlephp 获取用户浏览器版本代码在php中我们有个全局变量$_SERVER['HTTP_USER_AGENT'];可以获取用户所有信息,我们要经过处理才可以判断用户浏览器是...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn