php如何判断浏览器是否为ie
function isIE(){
$isIE = strpos($_SERVER['HTTP_USER_AGENT'],'compatible') !==false && strpos($_SERVER['HTTP_USER_AGENT'],'MSIE') !==false;
$isIE11 = strpos($_SERVER['HTTP_USER_AGENT'],'Trident') !==false && strpos($_SERVER['HTTP_USER_AGENT'],'rv:11.0') !==false;
if($isIE || $isIE11){
return true;
}else{
return false;
}
}
$isIE = strpos($_SERVER['HTTP_USER_AGENT'],'compatible') !==false && strpos($_SERVER['HTTP_USER_AGENT'],'MSIE') !==false;
$isIE11 = strpos($_SERVER['HTTP_USER_AGENT'],'Trident') !==false && strpos($_SERVER['HTTP_USER_AGENT'],'rv:11.0') !==false;
if($isIE || $isIE11){
return true;
}else{
return false;
}
}
php检测ie版本号
function IEVersion(){
$agent = strtolower($_SERVER['HTTP_USER_AGENT']);
if(strpos($agent, 'msie') !== false){
preg_match('/msie\s([^\s|;|\)]+)/i', $agent, $MSIERegs);
return (int)$MSIERegs[1];//ie11以下浏览器
}elseif (strpos($agent, 'trident') !== false && strpos($agent, 'rv:') !== false){
preg_match('/rv:([^\s|;|\)]+)/i', $agent, $rvRegs);
return (int)$rvRegs[1];//ie11
}else{
return 0;//不是ie
}
}
$agent = strtolower($_SERVER['HTTP_USER_AGENT']);
if(strpos($agent, 'msie') !== false){
preg_match('/msie\s([^\s|;|\)]+)/i', $agent, $MSIERegs);
return (int)$MSIERegs[1];//ie11以下浏览器
}elseif (strpos($agent, 'trident') !== false && strpos($agent, 'rv:') !== false){
preg_match('/rv:([^\s|;|\)]+)/i', $agent, $rvRegs);
return (int)$rvRegs[1];//ie11
}else{
return 0;//不是ie
}
}
我还讲过html和js判断浏览器是否为ie,以及检测ie版本号的方法: