Re: OS Detection

From: Date: Thu, 17 Nov 2005 16:52:47 +0000
Subject: Re: OS Detection
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-225998@lists.php.net to get a copy of this message
On Nov 17, 2005, at 10:09 AM, Rahul S. Johari wrote:
I'm working on a Guestbook for a site and I'm trying to identify Browser & Operating System of the user and eventually I'll display the Icon matching the Browser/OS in the entry. I'm able to identify and use an If Conditional statement for the Browser, but I can't seem to identify the OS. This is what I'm using to identify the Browser: function browser_detection( $which_test ) { // initialize the variables $browser = ''; $dom_browser = ''; // set to lower case to avoid errors, check to see if http_user_agent is set $navigator_user_agent = ( isset( $_SERVER['HTTP_USER_AGENT'] ) ) ? strtolower( $_SERVER['HTTP_USER_AGENT'] ) : ''; // run through the main browser possibilities, assign them to the main $browser variable if (stristr($navigator_user_agent, "opera")) { $browser = 'opera'; $dom_browser = true; }
[snip]
Any suggestions on getting the OS ?
If you're using the above to match parts of the $_SERVER["HTTP_USER_AGENT"] string, why not also use stristr() to look for "windows", "mac", etc.? -- Lowell Allen

« previous php.general (#225998) next »