Get browser and OS in PHP

I need to get browser and OS via php encoding.

I used $_SERVER['HTTP_USER_AGENT'] , but it 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 value?

Please help me..

Thanks in advance.

+3
source share
5 answers

You can use the google browser class . It essentially does the same thing as PHP get_browser (), but you don’t have to worry about updating your browser.

This worked for me:

 require('Browscap.php'); $browscap = new Browscap('/path/to/cache'); var_dump($browscap->getBrowser()); 
+3
source

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

+1
source

Take a copy of browsercap.ini compare $ _SERVER ['HTTP_USER_AGENT'] with this file.

0
source

The best way is to use the buil-in function get_browser (), because it is several times faster than the version of Google-Code, if you only run it once. (If you use it 4 times, the version of Google-Code is faster)

Therefore, if you do not need automatic updates and use only one check at a time, you should use the built-in version. :)

And it shouldn't be so hard to do a cronjob to get the latest version .;)

0
source

you can use simple explode ();

 <?php $ex=explode(' ',$_SERVER['HTTP_USER_AGENT']); echo 'OS: '.$ex[4].' '.$ex[5].' '.$ex[6].'/n'; echo 'Browser: '.$ex[0]; ?> 
-one
source

All Articles