9:32 pm
Mood: geeky

phpIntroduction
The one basic problem with Web design is that each and every browser is different. The way they render HTML or parse CSS differ depending on both browser, browser version, and all the other things “under the hood.” I don’t know the number of times I’ve had something looking really fantastic and then one browser decides it isn’t going to play nice. That browser could be Internet Explorer, Opera, Firefox, Chrome, or any of the others.

At this point you have several options. In this article, I cover basic browser detection using a simple PHP script. Browser detection isn’t always a good idea, mainly because it isn’t foolproof and can be seen as a lazy way out of the problem. However, I have had requests to help people with browser detection.

So let’s start with what we need: We need a way to tell what browsers our visitors are using and display specific content based on what they’re using.

One really nice thing is most browsers declare themselves to the Web sites they visit. We only have to ask for the information and it will usually be supplied. I say “usually” because there are some caveats, of course. As I said above, this isn’t foolproof.

To use this method, you must have a Web host that supports PHP. This probably won’t work on a free hosting service like Yahoo! Geocities, Quizilla, or Tripod.