Well, we’ve heard time and time again that IE6 needs to go away and stay away. Heck, even Microsoft wants it gone for good.
If you know the basics of PHP, below are code examples you can use to remind IE6 users to upgrade on your own web site, should you have one.
Requirements: A Linux or UNIX based web server running Apache and PHP. The vast majority of web host providers are set up like this. No database is required as it’s just code that reads browser user agent data.
Use one of the code examples below and paste it at the top of the code for your home page.
Friendly version
<?php
if (preg_match("/MSIE 6.0/i", $_SERVER['HTTP_USER_AGENT'])) {
echo ("
<span style='text-align: center;
width: 100%;
background-color: #cfc;
color: #000;
border: 1px solid #000;
padding: 1em;
font-family: sans-serif;
font-size: 1em;
'>
Hello! You appear to be using a
really old version of Internet
Explorer. You should upgrade!
</span>
");
}
When an IE6 user loads your site, they will see a green box at top with the message like this:

The "Hello, world!" part is where the rest of your web page would be.
Not-So Friendly version
if (preg_match("/MSIE 6.0/i", $_SERVER['HTTP_USER_AGENT'])) {
echo ("
<span style='text-align: justify;
width: 100%;
background-color: #f00;
color: #ff0;
border: 1px solid #000;
padding: 1em;
font-family: impact;
font-size: 4em;
'>
YOU ARE USING A REALLY OLD, AWFUL BROWSER THAT IS
RESPONSIBLE FOR SOGGY RICE KRISPIES, COMMUNISM AND
THE GOUT. THIS BROWSER IS IE6. IT IS BAD, THEREFORE
YOU ARE BAD. UPGRADE OR DIE, FOOL.
</span>
");
}
This will result in the IE6 user seeing this:

Just imagine what that would look like full-size (eek!)
Some webmasters just hate IE with a passion and want their users to know that if they use IE6 voluntarily or not on their site, they’ll be sorry for it. ![]()

Like what you read?
If so, please join over 28,000 people who receive our exclusive weekly newsletter and computer tips, and get FREE COPIES of 5 eBooks we created, as our gift to you for subscribing. Just enter your name and email below:



Sorry, but I think it’s bad idea to use php and regex (which is slow).
We can use only HTML:
http://pastebin.com/zSMjgUV3
If you want to use php, you can use faster function, such like:
http://www.php.net/manual/en/function.strstr.php
Sorry, but I think it’s bad idea to use php and regex (which is slow).
We can use only HTML:
http://pastebin.com/zSMjgUV3
If you want to use php, you can use faster function, such like:
http://www.php.net/manual/en/function.strstr.php