在PHP中针对特定版本的Internet Explorer

I am using the following PHP to target all browsers except Internet Explorer:

if(isset($_SERVER['HTTP_USER_AGENT']) && (strpos($_SERVER['HTTP_USER_AGENT'],'MSIE') == false)) {
   DO STUFF
   }

I now want to target specific versions of Internet Explorer, i.e. to exclude only IE8 and lower versions, as opposed to all versions of IE.

How would I adapt the code above to achieve this?

function ie($version) {

if (strpos($_SERVER['HTTP_USER_AGENT'], $version) !== false)
{ return true; }
return false;

}   

if (ie('MSIE 8.') == true || ie('MSIE 7.') == true || ie('MSIE 6.') == true) { 
echo "Do something";
}

I think you should look at get_browser

$browser = get_browser(null, true);
print_r($browser);

You can also do

$ie8 = (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE 8.') !== FALSE);

this function return the ie version

function detectIEversion() {
      ereg('MSIE ([0-9].[0-9])',$_SERVER['HTTP_USER_AGENT'],$reg);
      if(!isset($reg[1])) {
        return -1;
      } else {
        return floatval($reg[1]);
      }
    }