Reputation: 11
I need to get client version of the browser. The code I was using is:
if (strpos($_SERVER['HTTP_USER_AGENT'], 'Firefox') !== false) {
$browser = "Firefox";
} else if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false) {
$browser = "IE";
} else if (strpos($_SERVER['HTTP_USER_AGENT'], 'Chrome') !== false) {
$browser = "Chrome";
}
I had made a big search here and found the get_browser function, but it does need some configs files to be made. And I not going to do that on every user. So anyone could help me? Something that I could use to get browser information? Thanks
Upvotes: 0
Views: 5887
Reputation: 300
I have read this article PHP code to get Browser Information, I think this is what you wanted.
Hope this might help you
Thanks
Upvotes: 0
Reputation: 180
Rather than using browser detection which can easily be forged by the user, why don't you instead use a feature detection libary such as http://modernizr.com which detects the browsers features rather than the user agent.
To detect IE11 using the user agent you can use this code
$useragent = $_SERVER["HTTP_USER_AGENT"];
if (strpos($useragent, 'Trident/7.0; rv:11.0') != -1) {
// IE11
}
Upvotes: 4