<?php
/****************************************************************
*                                                               *
*   BROWSER AND PLATFORM DETECTION SCRIPT IN PHP                *
*                                                               *
*    Author:   Jed Record (jed@5-20.org)                        *
*    Date:     Feb, 2000                                        *
*    Updates:  http://5-20.org/jed                              *
*                                                               *
*    Please email me if you use this script,                    *
*    it's free but I will only update it if                     *
*    people are actually using it. -jed                         *
*                                                               *
*****************************************************************/
// set defaults
$maj_ver = "0";
$min_ver = "0";
$browser  = "other";
$platform = "other";
if (isset(
$HTTP_USER_AGENT)) {
    
//  Match IE, *MUST* be the first check
    
if (eregi("MSIE",$HTTP_USER_AGENT)) {
        
$browser = "IE";
        if(
eregi("MSIE[/|\| ]([0-9]).([0-9]|x)", $HTTP_USER_AGENT, $regs)){
        
$maj_ver = $regs[1];
        
$min_ver = $regs[2];
        }
    
//  Match Browsers that look like Netscape
    
} elseif (eregi("Mozilla",$HTTP_USER_AGENT)) {
        
$browser = "Netscape";
        if(
eregi("Mozilla[/|\| ]([0-9]).([0-9]|x)", $HTTP_USER_AGENT, $regs)){
        
$maj_ver = $regs[1];
        
$min_ver = $regs[2];
        }
    
//  all others get defaults (for now)
    
} else {
        
$browser = "other";
        if(
eregi("^[a-z]+[/|\| ]([0-9]).([0-9]|x)", $HTTP_USER_AGENT, $regs)){
        
$maj_ver = $regs[1];
        
$min_ver = $regs[2];
        }
    }
// Now check the platform
    // mac users
    
if (eregi("mac",$HTTP_USER_AGENT)) {
        
$platform = "mac";
    
// unix variants
    
} elseif (eregi("linux|unix|x11|bsd|solaris|sunos",$HTTP_USER_AGENT)){
        
$platform = "unix";
    
// microsoft windows
    
} elseif (eregi("win",$HTTP_USER_AGENT)) {
        
$platform = "windows";
    
// WebTV
    
} elseif (eregi("WebTV|AOL_TV",$HTTP_USER_AGENT)) {
        
$platform = "webtv";
    
// everyone else
    
} else {
        
$platform = "other";
    }
}
// show what we got:
echo "Your user agent string is: $HTTP_USER_AGENT <br>";
echo
"You appear to be using $browser $maj_ver.$min_ver on $platform";
?>
<br><a href="browser_detect.phps">view source</a>