your could simplify it with switch()
<?
//Gets the OS and Browser to add in Session
//Notice the $_SESSION variables and here are the built in functions
$OS=strtoupper(substr(PHP_OS, 0, 3));
$UserAgent=$_SERVER['HTTP_USER_AGENT'];
$clientip=$_SERVER['REMOTE_ADDR'];
$Client=gethostbyaddr($clientip);
class OSBrowser{
function OSBrowser($OS){
if(!isset($_SESSION['OS'])){
$this->GetOS($OS);
}
if(!isset($_SESSION['Browser'])){
$this->GetBrowser($OS);
}
}
function GetBrowser($StaticVars){
if (preg_match("|MSIE ([0-9].[0-9]{1,2})|",$UserAgent,$matched)) {
$browser_version=$matched[1];
$browser = "IE";
}
elseif (preg_match( "|Opera ([0-9].[0-9]{1,2})|",$UserAgent,$matched)) {
$browser_version=$matched[1];
$browser = "Opera";
}
elseif(preg_match("|Firefox/([0-9.]+)|",$UserAgent,$matched)) {
$browser_version=$matched[1];
$browser = "Firefox";
}
elseif(preg_match("|Safari/([0-9.]+)|",$UserAgent,$matched)) {
$browser_version=$matched[1];
$browser = "Safari";
}
else {
// browser not recognized!
$browser_version = 0;
$browser= "Unknown";
}
$_SESSION['Browser']=$browser;
$_SESSION['BrowserVersion']=$browser_version;
$_SESSION['client']=$Client;
}
function GetOS($OS){
$_SESSION['OS']=$OS;
}
}
?>