In PHP and Javascript by which function can we know what's end users operating system when an end user uses a site?
+4
A:
With an up-to-date browscap.ini, you can use the get_browser() php function.
For Javascript-based detection, check out this script from quirksmode.org
Paul Dixon
2009-08-16 11:50:31
+3
A:
In javascript:
navigator.platform gives you a general idea (win32 for example).
navigator.userAgent can be parsed with this regex: /^[^\(]*\((.*)]\)/
to give you what's in the first set of parentheses. This typically is split up into more sub-sections, for example:
"Windows; U; Windows NT 6.0; en-US; rv:1.9.1.3pre"
Zytrax maintains a wonderful list of useragents.
in PHP:
browser.php parses the user agent into the OS, Browser, and Browser version:
Keep in mind though that no matter how you detect it, it can be faked.
SEK
2009-08-16 12:07:39