public function match($userAgent = null, $accept = null)
	{
		// Set our agent string.
		if (is_null($userAgent))
		{
			if (isset($_SERVER['HTTP_USER_AGENT']))
			{
				$this->agent = trim($_SERVER['HTTP_USER_AGENT']);
			}
		}
		else
		{
			$this->agent = $userAgent;
		}

		$this->lowerAgent = strtolower($this->agent);

		// Set our accept string.
		if (is_null($accept))
		{
			if (isset($_SERVER['HTTP_ACCEPT']))
			{
				$this->accept = strtolower(trim($_SERVER['HTTP_ACCEPT']));
			}
		}
		else
		{
			$this->accept = strtolower($accept);
		}

		if (!empty($this->agent))
		{
			$this->_setPlatform();

			foreach ($this->regexes as $regex)
			{
				if (preg_match($regex['regex'], $this->agent, $version))
				{
					$this->browser  = strtolower($regex['name']);
					$this->platform = ($regex['platform'] ? $regex['platform'] : $this->platform);
					if (!$this->mobile)
					{
						$this->mobile   = $regex['mobile'];
					}

					if (isset($regex['version']))
					{
						if (preg_match($regex['version'], $this->agent, $ver))
						{
							$version = $ver;
						}
					}

					if (!empty($version) && isset($version[1]))
					{
						$bits = explode('.', $version[1]);

						$this->majorVersion = $bits[0];
						$this->minorVersion = (isset($bits[1]) ? $bits[1] : 0);
					}

					break;
				}
			}
		}
	}
public function match($userAgent = null, $accept = null)
	{
		// Set our agent string.
		if (is_null($userAgent))
		{
			if (isset($_SERVER['HTTP_USER_AGENT']))
			{
				$this->agent = trim($_SERVER['HTTP_USER_AGENT']);
			}
		}
		else
		{
			$this->agent = $userAgent;
		}

		$this->lowerAgent = strtolower($this->agent);

		// Set our accept string.
		if (is_null($accept))
		{
			if (isset($_SERVER['HTTP_ACCEPT']))
			{
				$this->accept = strtolower(trim($_SERVER['HTTP_ACCEPT']));
			}
		}
		else
		{
			$this->accept = strtolower($accept);
		}

		if (!empty($this->agent))
		{
			$this->_setPlatform();

			foreach ($this->regexes as $regex)
			{
				if (preg_match($regex['regex'], $this->agent, $version))
				{
					$this->browser  = strtolower($regex['name']);
					$this->platform = ($regex['platform'] ? $regex['platform'] : $this->platform);
					if (!$this->mobile)
					{
						$this->mobile   = $regex['mobile'];
					}

					if (isset($regex['version']))
					{
						if (preg_match($regex['version'], $this->agent, $ver))
						{
							$version = $ver;
						}
					}

					if (!empty($version) && isset($version[1]))
					{
						$bits = explode('.', $version[1]);

						$this->majorVersion = $bits[0];
						$this->minorVersion = (isset($bits[1]) ? $bits[1] : 0);
					}

					break;
				}
			}
		}
	}
public function match ( $ userAgent = null , $ accept = null ) { // Set our agent string. if ( is_null ( $ userAgent ) ) { if ( isset ( $ _SERVER [ 'HTTP_USER_AGENT' ] ) ) { $ this -> agent = trim ( $ _SERVER [ 'HTTP_USER_AGENT' ] ) ; } } else { $ this -> agent = $ userAgent ; } $ this -> lowerAgent = strtolower ( $ this -> agent ) ; // Set our accept string. if ( is_null ( $ accept ) ) { if ( isset ( $ _SERVER [ 'HTTP_ACCEPT' ] ) ) { $ this -> accept = strtolower ( trim ( $ _SERVER [ 'HTTP_ACCEPT' ] ) ) ; } } else { $ this -> accept = strtolower ( $ accept ) ; } if ( ! empty ( $ this -> agent ) ) { $ this -> _setPlatform ( ) ; foreach ( $ this -> regexes as $ regex ) { if ( preg_match ( $ regex [ 'regex' ] , $ this -> agent , $ version ) ) { $ this -> browser = strtolower ( $ regex [ 'name' ] ) ; $ this -> platform = ( $ regex [ 'platform' ] ? $ regex [ 'platform' ] : $ this -> platform ) ; if ( ! $ this -> mobile ) { $ this -> mobile = $ regex [ 'mobile' ] ; } if ( isset ( $ regex [ 'version' ] ) ) { if ( preg_match ( $ regex [ 'version' ] , $ this -> agent , $ ver ) ) { $ version = $ ver ; } } if ( ! empty ( $ version ) && isset ( $ version [ 1 ] ) ) { $ bits = explode ( '.' , $ version [ 1 ] ) ; $ this -> majorVersion = $ bits [ 0 ] ; $ this -> minorVersion = ( isset ( $ bits [ 1 ] ) ? $ bits [ 1 ] : 0 ) ; } break ; } } } }
Parses the user agent string and inititializes the object with
all the known features and quirks for the given browser.

@param   string  $userAgent  The browser string to parse.
@param   string  $accept     The HTTP_ACCEPT settings to use.
@return  void
Parses the user agent string and inititializes the object with all the known features and quirks for the given browser .