why $_SERVER['HTTP_USER_AGENT'] gives different result in Mozilla and MSIE?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • kailashchandra
    New Member
    • Sep 2008
    • 5

    why $_SERVER['HTTP_USER_AGENT'] gives different result in Mozilla and MSIE?

    [code=php]
    <html>
    <head>
    <title>PHP Test</title>
    </head>
    <body>
    <?php echo $_SERVER['HTTP_USER_AGEN T']; ?>
    </body>
    </html>
    [/code]

    when i have running the above code on my system,it gives two different result in Mozilla & MSIE Browser.I couldn't understand why?please guide me.?

    the result in Mozilla is:-Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.1) Gecko/2008070208 Firefox/3.0.1

    the result in MSIE is:-Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 2.0.50727; .NET CLR 3.0.04506.648; .NET CLR 3.5.21022)

    thanks.
    Last edited by Atli; Sep 9 '08, 06:44 PM. Reason: Added [code] tags.
  • Dormilich
    Recognized Expert Expert
    • Aug 2008
    • 8694

    #2
    This is because FF and IE are two different browsers (i.e.: user agents). A browser can set this string to any value it likes (e.g. Opera can identify itself as IE) but usually it gives properties of the browser (OS, browser language, name, rendering engine,...)

    regards

    Comment

    • Atli
      Recognized Expert Expert
      • Nov 2006
      • 5062

      #3
      This is exactly the purpose of the $_SERVER['HTTP_USER_AGEN T'] element; to identify the user agent (a.k.a. the browser) the request was sent from.

      Read the results you posted and you will see that each string is built to identify the browser, it's version and various other useful info.

      Also,
      Please use &#91;code] tags when posting you code examples.

      Thank you.

      Comment

      Working...