Here is a nice bit of code to do what you want
<?php
$OSList = array
(
// Match user agent string with operating systems
'Windows 95' => '(Windows 95)|(Win95)|(Windows_95)',
'Windows 98' => '(Windows 98)|(Win98)',
'Windows 2000' => '(Windows NT 5.0)|(Windows 2000)',
'Windows XP' => '(Windows NT 5.1)|(Windows XP)',
'Windows Server 2003' => '(Windows NT 5.2)',
'Windows Vista' => '(Windows NT 6.0)',
'Windows 7' => '(Windows NT 6.1)',
'Windows 8' => '(Windows NT 6.2)',
'Windows 8.1' => '(Windows NT 6.3)',
'Windows NT 4.0' => '(Windows NT 4.0)|(WinNT4.0)|(WinNT)|(Windows NT)',
'Windows ME' => 'Windows ME'
);
// Loop through the array of user agents and matching operating systems
foreach($OSList as $CurrOS=>$Match)
{
// Find a match
if (eregi($Match, $_SERVER['HTTP_USER_AGENT']))
{
// We found the correct match
break;
}
}
echo "We detect you are using ".$CurrOS."<br style='clear:both'>";
if ($CurrOS == "Windows XP")
{
echo "The alternative browsers you can download are:<br style='clear:both'><a target='_blank' href='http://google.com/chrome' style='color:white'>Google Chrome</a><br style='clear:both'><a target='_blank' href='http://mozilla.org/firefox' style='color:white'>Mozilla Firefox</a><br style='clear:both'><a target='_blank' href='http://opera.com' style='color:white'>Opera<br>";
}
elseif ($CurrOS == "Windows Vista")
{
echo "The alternative browsers you can download are:<br style='clear:both'><a target='_blank' href='http://google.com/chrome' style='color:white'>Google Chrome</a><br style='clear:both'><a target='_blank' href='http://mozilla.org/firefox' style='color:white'>Mozilla Firefox</a><br style='clear:both'><a target='_blank' href='http://opera.com' style='color:white'>Opera<br>";
}
elseif ($CurrOS == "Windows 7")
{
echo "The alternative browsers you can download are:<br style='clear:both'><a target='_blank' href='http://google.com/chrome' style='color:white'>Google Chrome</a><br style='clear:both'><a target='_blank' href='http://mozilla.org/firefox' style='color:white'>Mozilla Firefox</a><br style='clear:both'><a target='_blank' href='http://windows.microsoft.com/en-us/internet-explorer/ie-10-worldwide-languages' style='color:white'>Internet Explorer 10</a><br style='clear:both'><a target='_blank' href='http://windows.microsoft.com/en-us/internet-explorer/ie-11-worldwide-languages' style='color:white'>Internet Explorer 11</a><br style='clear:both'><a target='_blank' href='http://opera.com' style='color:white'>Opera<br>";
}
elseif ($CurrOS == "Windows 8")
{
echo "The alternative browsers you can download are:<br style='clear:both'><a target='_blank' href='http://google.com/chrome' style='color:white'>Google Chrome</a><br style='clear:both'><a target='_blank' href='http://mozilla.org/firefox' style='color:white'>Mozilla Firefox</a><br style='clear:both'><a target='_blank' href='http://windows.microsoft.com/en-us/internet-explorer/ie-10-worldwide-languages' style='color:white'>Internet Explorer 10</a><br style='clear:both'><a target='_blank' href='http://opera.com' style='color:white'>Opera<br>";
}
elseif ($CurrOS == "Windows 8.1")
{
echo "The alternative browsers you can download are:<br style='clear:both'><a target='_blank' href='http://google.com/chrome' style='color:white'>Google Chrome</a><br style='clear:both'><a target='_blank' href='http://mozilla.org/firefox' style='color:white'>Mozilla Firefox</a><br style='clear:both'><a target='_blank' href='http://windows.microsoft.com/en-us/internet-explorer/ie-11-worldwide-languages' style='color:white'>Internet Explorer 11</a><br style='clear:both'><a target='_blank' href='http://opera.com' style='color:white'>Opera<br>";
}
elseif ($CurrOs == "Windows ME" || $CurrOs == "Windows 98" || $CurrOs == "Windows 2000")
{
echo "The alternative browsers you can download are:<br style='clear:both'><a target='_blank' href='http://opera.com' style='color:white'>Opera<br>";
}
else
{
echo "<br>The version of windows you are currently using is not supported by any browsers better than Internet Explorer. We recommend you upgrade to a Windows XP, 7 or 8 machine to enjoy the best of the web<br>";
}
?>