php判断浏览器类型
By admin
- One minute read - 76 wordsUA = getenv(“HTTP_USER_AGENT”); $start = strpos($this->UA,”(“)+1;//查看起始位置 $length = strpos($this->UA,”)”)-$start;//查看结束位置 $middle = trim(substr($this->UA,$start,$length)); //查看内容 $end = trim(substr($this->UA,$start+$length+1));//附加内容 $message = explode(“;”,$middle);//转换成数组 //———-操作系统—————– $os = trim($message[‘2’]); $os_array = explode(” “,$os); $this->PLATFORM = trim($os_array[‘0’]);//操作系统 //————浏览器———— $brower = trim($message[‘1’]);
if(eregi(“msie”,$brower)){//IE核心浏览器 $brow_array =explode(” “,$brower); $this->BROWSER = “IE”; $this->VERSION = “”.$brow_array[‘1’]; }else{//其它浏览器 $brower =explode(” “,$end); $brow_array =explode(“/”,$brower[‘1’]); $this->BROWSER = $brow_array[‘0’]; $this->VERSION = $brow_array[‘1’]; } }//End Function }//End Class $test=new browserdetector; echo $test->UA.”
”; echo $test->PLATFORM.”
”; echo $test->BROWSER.”
”; echo $test->VERSION.”
”; ?>