How do I detect what browser is used to access my site?

前端 未结 11 2010
盖世英雄少女心
盖世英雄少女心 2021-01-13 13:51

How do I detect what browser (IE, Firefox, Opera) the user is accessing my site with? Examples in Javascript, PHP, ASP, Python, JSP, and any others you can think of would b

11条回答
  •  北荒
    北荒 (楼主)
    2021-01-13 14:14

    PHP's predefined superglobal array $_SERVER contains a key "HTTP_USER_AGENT", which contains the value of the User-Agent header as sent in the HTTP request. Remember that this is user-provided data and is not to be trusted. Few users alter their user-agent string, but it does happen from time to time.

提交回复
热议问题