3

I have a PHP page which breaks down in IE 6 and 7, hence I want users to not use IE. Warnings and notices will be definitely ignored by them. So as a solution, can I just stop rendering the page if the request come from IE and just display a line that IE is not supported?

I am new to php and hence the question. IE SUCKS!

user1263746
  • 5,788
  • 4
  • 24
  • 28

5 Answers5

3

Use user-agent checking:

if(stristr($_SERVER['HTTP_USER_AGENT'], 'MSIE 6.0')) {
    echo 'IE6'
};

if(stristr($_SERVER['HTTP_USER_AGENT'], 'MSIE 7.0')) {
    echo 'IE7';
};
Vlad Volkov
  • 147
  • 4
2

You can access the HTTP user agent request parameter with: $_SERVER['HTTP_USER_AGENT'].

$usingIE6 = (strpos( $_SERVER['HTTP_USER_AGENT'], 'MSIE 6.' ) !== FALSE);

if ($usingIE6) {
  echo 'Please upgrade your browser'; 
  exit;
}

Usage statistics are here, IE 6 has a 7% market share: http://marketshare.hitslink.com/browser-market-share.aspx?qprid=2&qpcustomd=0

chazmuzz
  • 75
  • 2
  • 7
1

Yes you can:

if (isset($_SERVER['HTTP_USER_AGENT']) && 
   (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false))

Its only a snippet and i know that the IE is not the best browser but a good programmer should look at all browsers and make it in all of them correct... this is the actual difficulty in web development.

René Höhle
  • 26,716
  • 22
  • 73
  • 82
  • I agree... IE 8 and onwards is good enough... but IE 6 and 7 are hell with CSS and JavaScript... hence I wanted to disable IE 6 and 7. – user1263746 Apr 06 '12 at 14:47
  • I partially agree. "A good programmer look at all browsers make it correct this is the difficulty on the web": sure but without IE that's the browser made with foot! If the bug are in the browser, why the programmator must fix them?? Microsoft MUST fix them! If all web-developers stop fixing IE's bugs, you'll see a better new version of IE. – user2342558 Mar 24 '17 at 13:21
1

you can make a test on the HTTP_USER_AGENT from the superglobal $_SERVER;

but just to give another option( that might not be what you need, as it fetches way more info and it needs an extra file) you could use get_browser that relies on browscap this is more in case you will sometime need other extra details about the visitor

mishu
  • 5,347
  • 1
  • 21
  • 39
0

PHP has a function called get_browser that will return all the version information you need.

You could also use conditional comments that IE will be able to decipher:

<!--[if lt IE 8]>Your browser is too old for this app. Please upgrade.<![endif]-->
Tony
  • 2,658
  • 2
  • 31
  • 46