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
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php