UA = 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(preg_match("/msie/i",$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']; } } }