HTTP_USER_AGENT如何工作? [英] How does HTTP_USER_AGENT work?

查看:91
本文介绍了HTTP_USER_AGENT如何工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可能重复:
为什么navigator.appCodeName返回Mozilla?

Possible Duplicate:
Why navigator.appCodeName returning Mozilla?

当我使用以下代码获取PHP服务器变量HTTP_USER_AGENT时:

When I get the PHP server variable HTTP_USER_AGENT with this code:

<?php
   $useragent = $_SERVER ['HTTP_USER_AGENT'];
   echo "<b>Your User Agent is</b>: " . $useragent;
?>

我在Google chrome中找到了它:

I get this in Google chrome:

Mozilla/5.0(Windows NT 6.1)AppleWebKit/537.4(KHTML,例如Gecko)Chrome/22.0.1229.94 Safari/537.4

Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.4 (KHTML, like Gecko) Chrome/22.0.1229.94 Safari/537.4

这在Firefox中:

This in firefox:

Mozilla/5.0(Windows NT 6.1; rv:16.0)Gecko/20100101 Firefox/16.0

Mozilla/5.0 (Windows NT 6.1; rv:16.0) Gecko/20100101 Firefox/16.0

这在IE中:

Mozilla/5.0(兼容; MSIE 9.0; Windows NT 6.1; Trident/5.0; BOIE9; NLNL)

Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0; BOIE9;NLNL)

我的明显问题是这是如何工作的.为什么在我使用Google chrome时用户代理说Mozilla和Windows NT?

My obvious question is how does this work. Why does my user-agent say Mozilla and Windows NT while I am using Google chrome?

为什么在使用IE时为什么说我使用firefox?

Also why does it say that I use firefox when I am using IE?

推荐答案

用户代理字符串是浏览器自己发送到网络服务器以标识自己的文本,以便网站可以基于浏览器或基于浏览器兼容性.

The user agent string is a text that the browsers themselves send to the webserver to identify themselves, so that websites can send different content based on the browser or based on browser compatibility.

Mozilla是浏览器渲染引擎(Firefox的核心),而Chrome和IE包含字符串Mozilla/4或/5的事实表明它们与该渲染引擎兼容.

Mozilla is a browser rendering engine (the one at the core of Firefox) and the fact that Chrome and IE contain the string Mozilla/4 or /5 identifies them as being compatible with that rendering engine.

这篇关于HTTP_USER_AGENT如何工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆