Code Snippet
PHP IE Detection
if ( eregi("MSIE", getenv( "HTTP_USER_AGENT" ) ) || eregi("Internet Explorer", getenv("HTTP_USER_AGENT" ) ) ) {
// do something
}if ( eregi("MSIE", getenv( "HTTP_USER_AGENT" ) ) || eregi("Internet Explorer", getenv("HTTP_USER_AGENT" ) ) ) {
// do something
}
Have a quick maybe stupid question. I need to detect all IE versions lower then 8. Can this just be done using the checks for if it’s ie 6 / 7 or is there an easier way
Browsers send their ID in a header file; I’m not sure if IE 8 sends anything unique from previous versions, but if you look at the header of it compared to other versions, you may find a useable text-string.
Make a script that echoes HTTP_USER_AGENT, find some folks who have earlier versions, have them send you the result, and see if any text string fits the bill.
Keep in mind, you may also want to differentiate between IEPC and IEMac.
I once used a switch statement with several browser options such as this snippet, and fed different CSS stylesheets to the output, depending on which browser was requesting a page. I didn’t parse between versions, however.
Important note: Some non-ie browsers include the substring MSIE in them. Namely Opera.
DigWP
A book and blog co-authored by Jeff Starr and myself about the World's most popular publishing platform.
Quotes on Design
Design, like Art, can be an elusive word to define and an awfully fun thing to have opinions about.
HTML-Ipsum
One-click copy to clipboard access to Lorem Ipsum text that comes wrapped in a variety of HTML.
Bookshelf
Hey Chris, what books do you recommend? These, young fertile mind, these.