Page 1 of 1

Collecting the user agent

Posted: Fri Apr 09, 2004 5:56 am
by therat
I have the following code that is suipposed to record the user agent of a visitor, but it does not show anything. I did not write this code, it comes from another stats script that I no longer have. Any suggestions as to why it does not work.

Code: Select all

function GetUserAgent() {
		if (isset($_SERVER['HTTP_USER_AGENT']))
		{
			if ($_SERVER['HTTP_USER_AGENT'] != NULL)
			{
				$this->GetUserAgent = strtolower((string)$_SERVER['HTTP_USER_AGENT']);	
			}
			else
			{	
				$this->GetUserAgent = '';
			}
		}
		else
		{
			$this->GetUserAgent = '';
		}
	}

hi

Posted: Fri Apr 09, 2004 6:05 am
by dipit
try this.
it is working on my machine

*************************************************************
<?php

function GetUserAgent() {
if (isset($_SERVER['HTTP_USER_AGENT']))
{
if ($_SERVER['HTTP_USER_AGENT'] != NULL)
{
$this->GetUserAgent = strtolower((string)$_SERVER['HTTP_USER_AGENT']);
}
else
{
$this->GetUserAgent = '';
}
}
else
{
$this->GetUserAgent = '';
}
echo $this->GetUserAgent;
}


GetUserAgent();

?>

*************************************************************
8O