Technology Programming

How to Gather Information with Server User Agent PHP



Gathering information with $_SERVER['HTTP_USER_AGENT']:

You can gather a lot of information about a person's computer by using $_SERVER['HTTP_USER_AGENT']. This can tell us more about the user's operating system, as well as their browser. For example I am revealed to be Mozilla/5.0 (Macintosh; U; PPC Mac OS X; en) AppleWebKit/418 (KHTML, like Gecko) Safari/417.9.3 when visiting a PHP page.

This can be useful to programmers if they are using special features that may not work for everyone, or if they want to get an idea of their target audience.

This also is important when using the get_browser() function for finding out more information about the browser's capabilities. By having this information the user can be directed to a version of your site best suited to their browser.

<?phpecho $_SERVER['HTTP_USER_AGENT']; ?>


Leave a reply