Detect web browsers

Hey there,
Im trying to detect web browsers and display the results
but then each time I tried in mozilla it appears ‘Other browsers’
in chrome it appears other browsers which is correct.


<?xml version = "1.0" encoding = "utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1 //EN"
 "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns = "http://www.w3.org/1999/xhtml">
 <head>
  <title>Date () in PHP</title>
 </head>
 <body>
	<?php
if ( strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') )
{
   $browser = 'Internet Explorer (MSIE/Compatible)';
  
}
else if ( strpos($_SERVER['HTTP_USER_AGENT'], 'Mozilla') )
{
   $browser = 'Mozilla Firefox';
}
else
{
   $browser = 'Other browsers';
}

echo $browser;
?>
 </body>
</html>


Do an echo of the value of $_SERVER[‘HTTP_USER_AGENT’], and see if it contains what you expect.

tried to do this


echo $_SERVER['HTTP_USER_AGENT'];


and I got this in chrome

Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_5_8; en-US) AppleWebKit/534.13 (KHTML, like Gecko) Chrome/9.0.597.102 Safari/534.13

no idea.

This will help you,
how to use the $_SERVER[‘HTTP_USER_AGENT’] and compare;

http://drupal.org/node/65903

Hi,
Use this easier code for detecting the browser below your your head section

<?php
$br = strtolower($_SERVER[‘HTTP_USER_AGENT’]); // what browser they use.

if(ereg(“msie”, $br)) {
header(“location: originalhomepage.php”);
} else {
header(“location: alteredhomepage.php”);
}
?>