Howdy. Bitviper is correct. I half-stole this when I wrote it for my site , but if you'd like to see an example of how the http user-agent string can be used, here you go!
<?php
$address = ($_SERVER['REMOTE_ADDR']);
$useragent = strtolower($_SERVER['HTTP_USER_AGENT']);
echo '<span class="phptext">Your external IP address is </span>';
echo '<span class="phptext">', $address, '</span>';
echo '<br>';
//The OS detection script used here was taken from geekpedia.com
//It is sightly modified for my purposes.
//The original code was by Andrew Pociu, and then modified by Kevin F.
/*It can be found here:
* http://www.geekpedia.com/code47_Detect-operating-system-from-user-agent-string.html
*/
$osList = array
(
'Windows 8' => 'windows nt 6.2',
'Windows 7' => 'windows nt 6.1',
'Windows Vista' => 'windows nt 6.0',
'Windows Server 2003' => 'windows nt 5.2',
'Windows XP' => 'windows nt 5.1',
'Windows 2000 sp1' => 'windows nt 5.01',
'Windows 2000' => 'windows nt 5.0',
'Windows NT 4.0' => 'windows nt 4.0',
'Windows Me' => 'win 9x 4.9',
'Windows 98' => 'windows 98',
'Windows 95' => 'windows 95',
'Windows CE' => 'windows ce',
'Windows (version unknown)' => 'windows',
'OpenBSD' => 'openbsd',
'SunOS' => 'sunos',
'Ubuntu (or a Ubuntu derivative)' => 'ubuntu',
'Android OS' => 'android',
'Apple iOS' => 'iphone',
'Linux' => '(linux)|(x11)',
'Mac OSX Beta (Kodiak)' => 'mac os x beta',
'Mac OSX Cheetah' => 'mac os x 10.0',
'Mac OSX Puma' => 'mac os x 10.1',
'Mac OSX Jaguar' => 'mac os x 10.2',
'Mac OSX Panther' => 'mac os x 10.3',
'Mac OSX Tiger' => 'mac os x 10.4',
'Mac OSX Leopard' => 'mac os x 10.5',
'Mac OSX Snow Leopard' => 'mac os x 10.6',
'Mac OSX Lion' => 'mac os x 10.7',
'Mac OSX (version unknown)' => 'mac os x',
'Mac OS (classic)' => '(mac_powerpc)|(macintosh)',
'QNX' => 'QNX',
'BeOS' => 'beos',
'OS2' => 'os/2',
'SearchBot'=>'(nuhk)|(googlebot)|(yammybot)|(openbot)|(slurp)|(msnbot)|(ask jeeves/teoma)|(ia_archiver)'
);
foreach($osList as $os=>$match)
{
if (preg_match('/' . $match . '/i', $useragent))
{
break;
}
else
{
$os = "Not automatically detected.<br>$useragent";
}
}
echo '<span class="phptext">Your Operating System is </span>';
echo <<<HEYHO
<span class="phptext">$os</span>;
HEYHO;
echo '<br>';
//I liked that code so much. I decided to make a browser checker from it.
$browlist = array
(
'Internet Explorer. Laaaame.' => 'msie',
'Mozilla Firefox. Good on ya!' => 'firefox',
'Google Chrome. Meh.' => 'chrome',
'Opera. Is your name Jake?' => 'opera',
);
foreach($browlist as $brow=>$check)
{
if (preg_match('/' . $check . '/i', $useragent))
{
break;
}
else
{
$brow = "a mystery! Gasp!<br>$useragent";
}
}
echo'<span class="phptext">Your browser is </span>';
echo <<<LETSGO
<span class="phptext">$brow</span>
LETSGO;
?>
If you'd like to see the end result check out www.thefunkspace.com, but be warned, I'm terribad at web design, so it looks horrendous. Also I don't have any good content on the site yet whatsoever. It's going to be remade with wordpress or drupal or something like that, and then it'll get some content.