I've got this variable from HTTP_USER_AGENT Which comes up as Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.8.0.1) Gecko/20060111 Firefox/1.5.0.1 Does anyone know how I can determine which browser that is actually looking at the site. How could I determine between IE and Mozilla Firefox?
A simple way that I use is: $useragent = getenv("HTTP_USER_AGENT"); if (preg_match("/MSIE/i", "$useragent")) { $browser= "MSIE"; } else if (preg_match("/Mozilla/i", "$useragent")) { $browser= "Firefox"; } else{ ........... } PHP:
I had 1 come up that had Mozilla and MSIE in the same user agent. Will that make a difference. I don't really know much about how the user agent variable is configured. Thanks for the help Mad
An error in the script I posted is that you should detect the word Firefox rather than Mozilla to find the firefox browser. This ties up with how the script at phpclasses does it.