开发者

Check Browser PHP and put results in .txt [duplicate]

开发者 https://www.devze.com 2023-04-08 02:27 出处:网络
This question already has answers here: Closed 11 years ago. Possible Duplicate: How can I detect the browser with PHP or JavaScript?
This question already has answers here: Closed 11 years ago.

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

0

精彩评论

暂无评论...
验证码 换一张
取 消