user1263746
user1263746

Reputation: 6308

Not rendering a PHP page to IE

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!

Upvotes: 3

Views: 181

Answers (5)

René Höhle
René Höhle

Reputation: 27305

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.

Upvotes: 1

Tony
Tony

Reputation: 2754

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

Upvotes: 0

chazmuzz
chazmuzz

Reputation: 75

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

Upvotes: 2

mishu
mishu

Reputation: 5397

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

Upvotes: 1

Vlad Volkov
Vlad Volkov

Reputation: 147

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';
};

Upvotes: 3

Related Questions