PHP detect Internet Explorer that is below version 10

后端 未结 3 998
长发绾君心
长发绾君心 2021-01-19 06:05

Could someone do this for me? As I only have macs and cannot test IE.

What\'s a good way of running an event IF the browser is Internet Explorer, and the version is

3条回答
  •  北荒
    北荒 (楼主)
    2021-01-19 06:35

    The function get_browser() may be used for feature detection.

    If you really want to only know the user's browser version you can look at the $_SERVER['HTTP_USER_AGENT'].

    A word of caution: although most users won't do this, it is possible to send a different user agent string to the server which might be done to e.g. protect ones privacy. If someone wants to go as far as sending you a user agent to be able to use your website though they'll probably know how to deal with any bugs that may come up.

    As a side question, what is the reason you're trying to limit your audience to IE 10 and up? Why not use a library such as Modernizr to fill in functions you might be missing in IE 9?

    EDIT: Some info regarding the IE 10 user agent string. You will want to read that so you know what to match your $_SERVER['HTTP_USER_AGENT'] against

提交回复
热议问题