Try this (blatantly pinched from the PHP Manual I might add):
Code:
<?php
function list_array ($array) {
while (list ($key, $value) = each ($array)) {
$str .= "<b>$key:</b> $value<br>\n";
}
return $str;
}
echo "$HTTP_USER_AGENT<hr>\n";
$browser = get_browser();
echo list_array ((array) $browser);
?>
The core bit is get_browser(), this will only work though if your host has installed the browscap.ini file, it works in PHP3 and PHP4 (I think it was broken in PHP4 until 4.0.3pl1).
If it doesn't work then you can try this:
Code:
if ( eregi( "MSIE ([[:digit:]]*\.[[:alnum:]]*)", $HTTP_USER_AGENT, $aRegs ) ) {
$agent[name] = "ie";
$agent[version] = $aRegs[1];
} elseif ( eregi ( "Mozilla/([[:digit:]]*\.[[:digit:]][[:alnum:]]*).*Gecko", $HTTP_USER_AGENT, $aRegs ) ) {
$agent[name] = "moz";
$agent[version] = $aRegs[1];
} elseif ( eregi ( "Mozilla/([[:digit:]]*\.[[:digit:]][[:alnum:]]*).*\(.*; [IU]", $HTTP_USER_AGENT, $aRegs ) ) {
$agent[name] = "nav";
$agent[version] = $aRegs[1];
} elseif ( eregi ( "Opera.([[:digit:]]*\.[[:alnum:]]*)", $HTTP_USER_AGENT, $aRegs ) ) {
$agent[name] = "opera";
$agent[version] = $aRegs[1];
}
Hope this helps you out. If you want the code by email (cos vB has probably trashed it) then let me know.
Bookmarks