Nobody likes to see a broken page.
If you know that you'll be using code which can "break" some browsers, you no longer have to resort to the old method of:
Choose your browser:
Internet Explorer 6 or Greater | Other
With PHP, you can redirect the user based on their browser! It's fast, simple and a good skill to have.
Here's the code:
<?php if ($check = strstr ($_SERVER['HTTP_USER_AGENT'], "MSIE")) { //if the browser is Microsoft IE Header ("Location: http://www.yoursite.com/index1.php"); //go to MSIE page } else { Header ("Location: http://www.yoursite.com/index2.php"); //else go to another page } ?> |
If we were to convert this to English, it would say:
- If user's browser is Microsoft Internet Explorer (MSIE), then go to index.php
- If user's browser is something else, go to index2.php
That's it! Wasn't that easy?