class Browser

Browser class, provides capability information about the current web client.

Browser identification is performed by examining the HTTPUSERAGENT environment variable provided by the web server.

This class has many influences from the lib/Browser.php code in version 3 of Horde by Chuck Hagenbuch and Jon Parise.

Methods

__construct( string $userAgent = null, string $accept = null)

Create a browser instance (constructor).

static  Browser
getInstance( string $userAgent = null, string $accept = null)

Returns the global Browser object, only creating it if it doesn't already exist.

void
match( string $userAgent = null, string $accept = null)

Parses the user agent string and inititializes the object with all the known features and quirks for the given browser.

string
getPlatform()

Return the currently matched platform.

void
setBrowser( string $browser)

Sets the current browser.

string
getBrowser()

Retrieve the current browser.

integer
getMajor()

Retrieve the current browser's major version.

integer
getMinor()

Retrieve the current browser's minor version.

string
getVersion()

Retrieve the current browser's version.

string
getAgentString()

Return the full browser agent string.

string
getHTTPProtocol()

Returns the server protocol in use on the current server.

boolean
isViewable( string $mimetype)

Determines if a browser can display a given MIME type.

boolean
isBrowser( string $browser)

Determine if the given browser is the same as the current.

boolean
isRobot()

Determines if the browser is a robot or not.

boolean
isMobile()

Determines if the browser is mobile version or not.

boolean
isSSLConnection()

Determine if we are using a secure (SSL) connection.

Details

__construct( string $userAgent = null, string $accept = null)

Create a browser instance (constructor).

Parameters

string $userAgent The browser string to parse.
string $accept The HTTP_ACCEPT settings to use.

static Browser getInstance( string $userAgent = null, string $accept = null)

Returns the global Browser object, only creating it if it doesn't already exist.

Parameters

string $userAgent The browser string to parse.
string $accept The HTTP_ACCEPT settings to use.

Return Value

Browser The Browser object.

void match( string $userAgent = null, string $accept = null)

Parses the user agent string and inititializes the object with all the known features and quirks for the given browser.

Parameters

string $userAgent The browser string to parse.
string $accept The HTTP_ACCEPT settings to use.

Return Value

void

string getPlatform()

Return the currently matched platform.

Return Value

string The user's platform.

void setBrowser( string $browser)

Sets the current browser.

Parameters

string $browser The browser to set as current.

Return Value

void

string getBrowser()

Retrieve the current browser.

Return Value

string The current browser.

integer getMajor()

Retrieve the current browser's major version.

Return Value

integer The current browser's major version

integer getMinor()

Retrieve the current browser's minor version.

Return Value

integer The current browser's minor version.

string getVersion()

Retrieve the current browser's version.

Return Value

string The current browser's version.

string getAgentString()

Return the full browser agent string.

Return Value

string The browser agent string

string getHTTPProtocol()

Returns the server protocol in use on the current server.

Return Value

string The HTTP server protocol version.

boolean isViewable( string $mimetype)

Determines if a browser can display a given MIME type.

Note that image/jpeg and image/pjpeg appear to be the same entity, but Mozilla doesn't seem to want to accept the latter. For our purposes, we will treat them the same.

Parameters

string $mimetype The MIME type to check.

Return Value

boolean True if the browser can display the MIME type.

boolean isBrowser( string $browser)

Determine if the given browser is the same as the current.

Parameters

string $browser The browser to check.

Return Value

boolean Is the given browser the same as the current?

boolean isRobot()

Determines if the browser is a robot or not.

Return Value

boolean True if browser is a known robot.

boolean isMobile()

Determines if the browser is mobile version or not.

Return Value

boolean True if browser is a known mobile version.

boolean isSSLConnection()

Determine if we are using a secure (SSL) connection.

Return Value

boolean True if using SSL, false if not.