I recently started wondering about sites like http://thismachine.info/ that get the user\'s operating system info. I have not been able to find out how to do that with PHP,
You can look for this information in $_SERVER['HTTP_USER_AGENT']
, but its format is free-form, not guaranteed to be sent, and could easily be altered by the user, whether for privacy or other reasons.
If you've not set the browsecap
directive, this will return a warning. To make sure it's set, you can retrieve the value using ini_get
and see if it's set.
if(ini_get("browscap")) {
$browser = get_browser(null, true);
$browser = get_browser($_SERVER['HTTP_USER_AGENT']);
}
As kba explained in his answer, your browser sends a lot of information to the server while loading a webpage. Most websites use these User-agent information to determine the visitor's operating system, browser and various information.