Okay, take this user agent for example:
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.6) Gecko/20100625
Curious as to what all of it means. I can figure out a few things, obviously, such as Mozilla == Firefox, and Windows NT 5.1 == Windows XP. But what is the开发者_C百科 rv:1.9.2.6, and What is Gecko? and U?
And also, I'm working on setting up a script that puts various pieces of it into separate variables, such as the Mozilla, and the Windows NT 5.1, but how would I go about using RegEx to extract that, if most (if not all) of the other sections in the User Agent would by dynamic based on each user?
Let's see: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.6) Gecko/20100625
Mozilla/5.0
- meaningless artifact from the era of the dinosaurs; nowadays, almost every browser identifies as Mozilla (even IE, Chrome, and Opera).Windows
- OSU
- strong security available (N
would stand for "no security" andI
for "weak security")Windows NT 5.1
- OS version. 5.1 is Windows XP, 6.0 is Vista, 6.1 is Windows "It's Not Vista SP" 7en-US
- browser locale - in this case, English - Americanrv:1.9.2.6
- version of the Gecko rendererGecko/20100625
- renderer build date: 2010-06-25
Anyway, this header is essentially meaningless, as several browsers provide ways of spoofing it (at least Firefox and Opera).
I recommending to examine this PHP script - http://chrisschuld.com/projects/browser-php-detecting-a-users-browser-from-php/
For the specific Mozilla string you mention, see the user-agent string documentation. The U
stands for "strong (encryption) security"; rv/xyz
is the version number and date of the Gecko rendering engine.
If you're not doing this for the learning process, there are several good libraries out there for browser detection, including PHP's native get_browser()
.
I recommend http://user-agent-string.info/ which has both online API and downloadable libraries for UA analysis.
Maybe you should take a look at get_browser.
精彩评论