0

In PHP and Javascript by which function can we know what's end users operating system when an end user uses a site?

2 Answers 2

4

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

Sign up to request clarification or add additional context in comments.

Comments

3

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.