Wikus Moller wrote:
> Hi.
>
> I want to strip everything after a / in the HTTP_USER_AGENT for
> example: Opera 9.10/blah/blah would become only Opera 9.10
>
> Lets say
> $user = $_SERVER["HTTP_USER_AGENT"];
> $browser = ("/", $user);
>
> Is this correct?
> Isn't something needed in the browser variable?
>
> Thanks
> Wikus
Are you looking for a regular expression? The user agent strings are
varied. For instance,
Internet Explorer 6:
Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR
1.1.4322; .NET CLR 2.0.50727)
Firefox 2:
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.1)
Gecko/20061204 Firefox/2.0.0.1
Opera 9.02 on linux:
Opera/9.02 (X11; Linux i686; U; en)
Opera 9.01 on Windows:
Opera/9.01 (Windows NT 5.0; U; en)
The Opera string format which you give ("Opera 9.10/blah/blah") doesn't
show up in the Apache log files I checked. In each case the version
number follows a forward slash, as in the examples above.
As for IE, you can see that it announces itself as Mozilla, so that you
have to look further to find out that it's IE. This is a relic of the
Netscape/IE browser wars.
Look at the source code for a standard javascript sniffer:
http://www.webreference.com/tools/br...avascript.html
It will give you an idea of what's involved in identifying browsers.
Google for php browser sniffers; there are tons of them out there.
--
_____________________
Myron Turner
http://www.room535.org http://www.bstatzero.org http://www.mturner.org/XML_PullParser/