Don't show PHP page in IE
I have a PHP page that breaks on IE 6 and 7, so I want to prevent users from using IE. Warnings and notifications will definitely be ignored by them. As a solution, can I just stop rendering the page if the request comes from IE and just displays a string that IE is not supported on?
I am new to php and hence the question. IE SUCKS!
source to share
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 stats are here, IE 6 has a 7% market share: http://marketshare.hitslink.com/browser-market-share.aspx?qprid=2&qpcustomd=0
source to share
Yes, you can:
if (isset($_SERVER['HTTP_USER_AGENT']) &&
(strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false))
Its the only snippet and I know IE is not the best browser, but a good programmer should look at all browsers and make it all correct ... this is a real problem in web development.
source to share
you can do a test for HTTP_USER_AGENT from the $ _SERVER superglobal;
but just to give another option (this may not be what you want as it asks for more information and needs an additional file) you can use get_browser which is browser dependent , that's more if you ever need some other additional information about the visitor is needed.
source to share
PHP has a get_browser function that will return all the version information you need.
You can also use conditional comments that IE will be able to decode:
<!--[if lt IE 8]>Your browser is too old for this app. Please upgrade.<![endif]-->
source to share