1. Technology
You can opt-out at any time. Please refer to our privacy policy for contact information.

$_SERVER['HTTP_USER_AGENT']

By

Woman typing on her computer
Chris Gramly/E+/Getty Images

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.

<?php 
 echo $_SERVER['HTTP_USER_AGENT'];
 ?> 
Related Video
Basic PHP Syntax
How to Create a PHP Calendar
  1. About.com
  2. Technology
  3. PHP / MySQL
  4. Learn PHP
  5. $_SERVER['HTTP_USER_AGENT'] - PHP HTTP User Agent

©2014 About.com. All rights reserved.