Possible Duplicate:
How can I detect the browser with PHP or JavaScript?
I want to check what browser visitors to my site are using, and then save the results to a file named browser.txt on my server. Any i开发者_StackOverflowdeas? Thanks
Why not just install Google Analytics which does that (and an awful lot more) for you (albeit it doesn't store the data on your server)? Alternatively you could just check your server logs, the data should also be in there.
file_put_contents(
__DIR__ . '/browser.txt',
$_SERVER['HTTP_USER_AGENT'],
FILE_APPEND
);
In php you can do this:
get_browser( $_SERVER['HTTP_USER_AGENT']);
it will return an object/array containing all the information you need. thake a look at PHP get_browser
精彩评论