Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Retrieve browser and OS in PHP

I need to retrieve the browser and OS through php coding.

I had used $_SERVER['HTTP_USER_AGENT'], but its shows the following

Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 2.0.50727; .NET CLR 1.1.4322; IEMB3)

How can I separate the browser and OS from the above received value?

Please guide me..

Thanks in advance.

like image 828
praveenjayapal Avatar asked Apr 08 '26 22:04

praveenjayapal


2 Answers

You could use the Google code Browscap class. It essentially does the same thing as PHP's get_browser(), but you don't have to worry about keeping your browscap.ini up to date.

This worked for me:

require('Browscap.php');
$browscap = new Browscap('/path/to/cache');
var_dump($browscap->getBrowser());
like image 61
user37125 Avatar answered Apr 11 '26 14:04

user37125


Just use the built in function for this http://ie.php.net/manual/en/function.get-browser.php

like image 34
Kudos Avatar answered Apr 11 '26 12:04

Kudos



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!