简体   繁体   中英

PHP detect Internet Explorer that is below version 10

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 under 10. So say it's IE 7, it will show the error, or if it's IE 9.9, it will show the error, however if it's IE 10, 10.1, 10.0.1 etc it will not show the error.

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 eg 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM