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"
<html xmlns = "">
  <title>Date () in PHP</title>
if ( strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') )
   $browser = 'Internet Explorer (MSIE/Compatible)';
else if ( strpos($_SERVER['HTTP_USER_AGENT'], 'Mozilla') )
   $browser = 'Mozilla Firefox';
   $browser = 'Other browsers';

echo $browser;

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

tried to do this


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;

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

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

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