PHP / MySQL

  1. Home
  2. Computing & Technology
  3. PHP / MySQL

$_SERVER['HTTP_USER_AGENT']

By Angela Bradley, About.com

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'];
?>

Explore PHP / MySQL

About.com Special Features

Build Your Own Website

Step-by-step advice on how to do everything from choosing a Web host to promoting your content. More >

Connect Your Home Computers

Easy ways to connect two computers for networking purposes. More >

PHP / MySQL

  1. Home
  2. Computing & Technology
  3. PHP / MySQL
  4. Learn PHP
  5. $_SERVER['HTTP_USER_AGENT'] - PHP HTTP User Agent - Server User Agent PHP

©2009 About.com, a part of The New York Times Company.

All rights reserved.