Back to Browser class

Method getInstance

public static \Joomla\CMS\Environment\Browser
getInstance
(mixed $userAgent = null, mixed $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.
Returns
  • \Joomla\CMS\Environment\Browser The Browser object.
Since
  • 1.7.0
Class: Browser
Project: Joomla

Method getInstance - Source code

/**
 * Returns the global Browser object, only creating it
 * if it doesn't already exist.
 *
 * @param   string  $userAgent  The browser string to parse.
 * @param   string  $accept     The HTTP_ACCEPT settings to use.
 *
 * @return  Browser  The Browser object.
 *
 * @since   1.7.0
 */
public static function getInstance($userAgent = null, $accept = null)
{
    $signature = serialize(array($userAgent, $accept));
    if (empty(self::$instances[$signature])) {
        self::$instances[$signature] = new static($userAgent, $accept);
    }
    return self::$instances[$signature];
}