Jump to content
xisto Community
Sign in to follow this  
nirvaman

How To Get The User's Browser And Operating System's Informations Tutorial to get and show on your webpage , the users browser and

Recommended Posts

Hi to all
After a long time , i came today with a script that will help you get and show the users browse and os informations on your webpage.
Here we go:

<?php$agent = $_SERVER['HTTP_USER_AGENT']; $browserArray = array(        'Windows Mobile' => 'IEMobile','Android Mobile' => 'Android','iPhone Mobile' => 'iPhone','Firefox' => 'Firefox',        'Google Chrome' => 'Chrome',        'Internet Explorer' => 'MSIE',        'Opera' => 'Opera',        'Safari' => 'Safari'); foreach ($browserArray as $k => $v) {    if (preg_match("/$v/", $agent)) {         break;    } else { $k = "Browser Unknown";    }} $browser = $k;$osArray = array(        'Windows 98' => '(Win98)|(Windows 98)',        'Windows 2000' => '(Windows 2000)|(Windows NT 5.0)','Windows ME' => 'Windows ME',        'Windows XP' => '(Windows XP)|(Windows NT 5.1)',        'Windows Vista' => 'Windows NT 6.0',        'Windows 7' => '(Windows NT 6.1)|(Windows NT 7.0)',        'Windows NT 4.0' => '(WinNT)|(Windows NT 4.0)|(WinNT4.0)|(Windows NT)','Linux' => '(X11)|(Linux)','Mac OS' => '(Mac_PowerPC)|(Macintosh)|(Mac OS)'); foreach ($osArray as $k => $v) {    if (preg_match("/$v/", $agent)) {         break;    } else { $k = "Unknown OS";    }} $os = $k;// Now you can do whatever you wanna do with the users browser and os informations for exampleecho '<h1>User Browser and Operating System</h1>';echo $agent;echo "<h2>You are using: <em>$browser - $os</em></h2>";?>

Try the code and if you do like it , they drope me a thank ;)

Share this post


Link to post
Share on other sites

I always prefer JS behind the site's background for knowing this information. Infact most of the analytics site use this method to understand the user and browser behavior. I never came across any script that shows browser information using PHP code or java code. So thanks for sharing this on forum.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.