Examine the headers of an HTTP request to determine what content is best suited for the browser making the request.
Let's say you've decided to have different versions of the content on your web site for desktop browsers than for the BlackBerry Browser. What is the best way to make these versions available to your users? You could make the different versions available at different URLs. For example, http://www.site.com would be for regular browsers while http://wap.site.com would be your URL for WAP browsers. While this approach certainly works, it forces your users to remember two different URLs for essentially the same content. It would be more convenient to use a single URL for your site and have your web application determine the content that should be provided, depending on the browser making the request. How can you check to see what type of browser is making a request to your web application?
There is a right way and wrong (read: easy) way to do this in your application. The good news is that the wrong way is okay to do in certain situations. There are two different HTTP headers that are available to your web application to help determine the browser type:
HTTP_USER_AGENT,or user agent string, is used by browsers as a way of advertising their browser type. This string has information about that identifies the browser and version along with general details about your operating ...