Get operating system info

后端 未结 7 1107
借酒劲吻你
借酒劲吻你 2020-11-22 14:48

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,

相关标签:
7条回答
  • 2020-11-22 15:45

    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.

    0 讨论(0)
提交回复
热议问题