BrowserDetection
in package
The BrowserDetection class facilitates the identification of the user's environment such as Web browser, version, platform and device type.
Typical usage:
$browser = new Wolfcast\BrowserDetection();
if ($browser->getName() == Wolfcast\BrowserDetection::BROWSER_FIREFOX &&
$browser->compareVersions($browser->getVersion(), '5.0') >= 0) {
echo 'You are using FireFox version 5 or greater.';
}
The class is a rewrite of Chris Schuld's Browser class version 1.9 which is mostly unmaintained since August 20th, 2010. Chris' class was based on the original work from Gary White.
Updates:
2024-04-21: Version 2.9.8
- Added macOS Sonoma and macOS Ventura detection. Note that all the majors Web browsers have reported macOS Catalina since 2021 for any macOS 11+ versions. See the documentation of macVerToStr() for more details.
- Improved the library documentation when detecting Windows version names since Windows 11 is always reported as Windows 10. See windowsNTVerToStr() for more details.
- Updated HTML documentation of the library to the latest version of phpDocumentor.
2022-09-20: Version 2.9.7
- Changed licensing to dual licensing: MIT or LGPL-3.0-only. This has no impact on existing users. You can continue under the previous license or switch to MIT.
2022-05-01: Version 2.9.6
- Added support for Chrome OS.
- Added support for macOS Monterey and macOS Big Sur.
- Now correctly detects AArch64 as 64-bit.
- Added support for PHP 8.
- Tested with latest Web Browsers and platforms.
2020-02-02: Version 2.9.5
- WARNING! Breaking change: complete rework of robots detection. Now robot name and version is detected in addition of browser name and version. Use getRobotName() and getRobotVersion() when isRobot() is true.
- WARNING! Breaking change: due to robots detection rework the following methods signatures has changed (isRobot parameter removed): addCustomBrowserDetection(), checkSimpleBrowserUA(), checkBrowserUAWithVersion().
- Added possibility to support new robots with addCustomRobotDetection().
- Added support for the new Microsoft Edge based on Chromium.
- Added version names for Android 10 and later (Google no longer use candy names for new versions).
- Added macOS Catalina detection.
- Added Windows Server 2019 detection (Windows Server 2016 can be no longer detected due to the fact that they both use the same version number and that the build is not included in the user agent).
2019-03-27: Version 2.9.3
- Fixed Edge detection on Android.
- Added Android Q detection.
- Now filtering superglobals.
2019-02-28: Version 2.9.2
- Fixed Opera detection.
2018-08-23: Version 2.9.1
- Fixed Chrome detection under iOS.
- Added Android Pie detection.
- Added macOS Mojave detection.
2018-07-15: Version 2.9.0
- WARNING! Breaking change: new Wolfcast namespace. Use new Wolfcast\BrowserDetection().
- iPad, iPhone and iPod are all under iOS now.
- Added Android Oreo detection.
- Added macOS High Sierra detection.
- Added UC Browser detection.
- Improved regular expressions (even less false positives).
- Removed AOL detection.
- Removed the following Web browsers detection: Amaya, Galeon, NetPositive, OmniWeb, Vivaldi detection (use addCustomBrowserDetection()).
- Removed the following legacy platforms detection: BeOS, OS/2, SunOS (use addCustomPlatformDetection()).
2016-11-28: Version 2.5.1
- Better detection of 64-bit platforms.
2016-08-19: Version 2.5.0
- Platform version and platform version name are now supported for Mac.
- Fixed platform version name for Android.
2016-08-02: Version 2.4.0
- Platform version and platform version name are now supported for Android.
- Added support for the Samsung Internet browser.
- Added support for the Vivaldi browser.
- Better support for legacy Windows versions.
2016-02-11: Version 2.3.0
- WARNING! Breaking change: public method getBrowser() is renamed to getName().
- WARNING! Breaking change: changed the compareVersions() return values to be more in line with other libraries.
- You can now get the exact platform version (name or version numbers) on which the browser is run on with getPlatformVersion(). Only working with Windows operating systems at the moment.
- You can now determine if the browser is executed from a 64-bit platform with is64bitPlatform().
- Better detection of mobile platform for Googlebot.
2016-01-04: Version 2.2.0
- Added support for Microsoft Edge.
2014-12-30: Version 2.1.2
- Better detection of Opera.
2014-07-11: Version 2.1.1
- Better detection of mobile devices and platforms.
2014-06-04: Version 2.1.0
- Added support for IE 11+.
2013-05-27: Version 2.0.0 which is (almost) a complete rewrite based on Chris Schuld's Browser class version 1.9 plus changes below.
- Added support for Opera Mobile
- Added support for the Windows Phone (formerly Windows Mobile) platform
- Added support for BlackBerry Tablet OS and BlackBerry 10
- Added support for the Symbian platform
- Added support for Bingbot
- Added support for the Yahoo! Multimedia crawler
- Removed iPhone/iPad/iPod browsers since there are not browsers but platforms - test them with getPlatform()
- Removed support for Shiretoko (Firefox 3.5 alpha/beta) and MSN Browser
- Merged Nokia and Nokia S60
- Updated some deprecated browser names
- Many public methods are now protected
- Documentation updated
2010-07-04:
- Added detection of IE compatibility view - test with getIECompatibilityView()
- Added support for all (deprecated) Netscape versions
- Added support for Safari < 3.0
- Better Firefox version parsing
- Better Opera version parsing
- Better Mozilla detection
Tags
Table of Contents
Constants
- BROWSER_ANDROID = 'Android'
- BROWSER_BLACKBERRY = 'BlackBerry'
- BROWSER_CHROME = 'Chrome'
- BROWSER_EDGE = 'Edge'
- BROWSER_FIREBIRD = 'Firebird'
- BROWSER_FIREFOX = 'Firefox'
- BROWSER_ICAB = 'iCab'
- BROWSER_ICECAT = 'GNU IceCat'
- BROWSER_ICEWEASEL = 'GNU IceWeasel'
- BROWSER_IE = 'Internet Explorer'
- BROWSER_IE_MOBILE = 'Internet Explorer Mobile'
- BROWSER_KONQUEROR = 'Konqueror'
- BROWSER_LYNX = 'Lynx'
- BROWSER_MOZILLA = 'Mozilla'
- BROWSER_MSNTV = 'MSN TV'
- BROWSER_NETSCAPE = 'Netscape'
- BROWSER_NOKIA = 'Nokia Browser'
- BROWSER_OPERA = 'Opera'
- BROWSER_OPERA_MINI = 'Opera Mini'
- BROWSER_OPERA_MOBILE = 'Opera Mobile'
- BROWSER_PHOENIX = 'Phoenix'
- BROWSER_SAFARI = 'Safari'
- BROWSER_SAMSUNG = 'Samsung Internet'
- BROWSER_TABLET_OS = 'BlackBerry Tablet OS'
- BROWSER_UC = 'UC Browser'
- BROWSER_UNKNOWN = 'unknown'
- PLATFORM_ANDROID = 'Android'
- PLATFORM_BLACKBERRY = 'BlackBerry'
- PLATFORM_CHROME_OS = 'Chrome OS'
- PLATFORM_FREEBSD = 'FreeBSD'
- PLATFORM_IOS = 'iOS'
- PLATFORM_LINUX = 'Linux'
- PLATFORM_MACINTOSH = 'Macintosh'
- PLATFORM_NETBSD = 'NetBSD'
- PLATFORM_NOKIA = 'Nokia'
- PLATFORM_OPENBSD = 'OpenBSD'
- PLATFORM_OPENSOLARIS = 'OpenSolaris'
- PLATFORM_SYMBIAN = 'Symbian'
- PLATFORM_UNKNOWN = 'unknown'
- PLATFORM_VERSION_UNKNOWN = 'unknown'
- PLATFORM_WINDOWS = 'Windows'
- PLATFORM_WINDOWS_CE = 'Windows CE'
- PLATFORM_WINDOWS_PHONE = 'Windows Phone'
- ROBOT_BINGBOT = 'Bingbot'
- ROBOT_GOOGLEBOT = 'Googlebot'
- ROBOT_MSNBOT = 'MSNBot'
- ROBOT_SLURP = 'Yahoo! Slurp'
- ROBOT_UNKNOWN = ''
- ROBOT_VERSION_UNKNOWN = ''
- ROBOT_W3CVALIDATOR = 'W3C Validator'
- ROBOT_YAHOO_MM = 'Yahoo! Multimedia'
- VERSION_UNKNOWN = 'unknown'
- Version unknown constant.
Properties
- $_agent : string
- $_browserName : string
- $_compatibilityViewName : string
- $_compatibilityViewVer : string
- $_customBrowserDetection : array<string|int, mixed>
- $_customPlatformDetection : array<string|int, mixed>
- $_customRobotDetection : array<string|int, mixed>
- $_is64bit : bool
- $_isMobile : bool
- $_isRobot : bool
- $_platform : string
- $_platformVersion : string
- $_robotName : string
- $_robotVersion : string
- $_version : string
Methods
- __construct() : mixed
- BrowserDetection class constructor.
- __toString() : string
- Determine how the class will react when it is treated like a string.
- addCustomBrowserDetection() : bool
- Dynamically add support for a new Web browser.
- addCustomPlatformDetection() : bool
- Dynamically add support for a new platform.
- addCustomRobotDetection() : bool
- Dynamically add support for a new robot.
- compareVersions() : int
- Compare two version number strings.
- getIECompatibilityView() : mixed
- Get the name and version of the browser emulated in the compatibility view mode (if any). Since Internet Explorer 8, IE can be put in compatibility mode to make websites that were created for older browsers, especially IE 6 and 7, look better in IE 8+ which renders web pages closer to the standards and thus differently from those older versions of IE.
- getLibVersion() : string
- Return the BrowserDetection class version.
- getName() : string
- Get the name of the browser. All of the return values are class constants. You can compare them like this: $myBrowserInstance->getName() == BrowserDetection::BROWSER_FIREFOX.
- getPlatform() : string
- Get the name of the platform family on which the browser is run on (such as Windows, Apple, etc.). All of the return values are class constants. You can compare them like this: $myBrowserInstance->getPlatform() == BrowserDetection::PLATFORM_ANDROID.
- getPlatformVersion() : string
- Get the platform version on which the browser is run on. It can be returned as a string number like 'NT 6.3' or as a name like 'Windows 8.1'. When returning version string numbers for Windows NT OS families the number is prefixed by 'NT ' to differentiate from older Windows 3.x & 9x release. At the moment only the Windows and Android operating systems are supported.
- getRobotName() : string
- Get the name of the robot. All of the return values are class constants. You can compare them like this: $myBrowserInstance->getRobotName() == BrowserDetection::ROBOT_GOOGLEBOT.
- getRobotVersion() : string
- Get the version of the robot.
- getUserAgent() : string
- Get the user agent value used by the class to determine the browser details.
- getVersion() : string
- Get the version of the browser.
- is64bitPlatform() : bool
- Determine if the browser is executed from a 64-bit platform. Keep in mind that not all platforms/browsers report this and the result may not always be accurate.
- isChromeFrame() : bool
- Determine if the browser runs Google Chrome Frame (it's a plug-in designed for Internet Explorer 6+ based on the open-source Chromium project - it's like a Chrome browser within IE).
- isInIECompatibilityView() : bool
- Determine if the browser is in compatibility view or not. Since Internet Explorer 8, IE can be put in compatibility mode to make websites that were created for older browsers, especially IE 6 and 7, look better in IE 8+ which renders web pages closer to the standards and thus differently from those older versions of IE.
- isMobile() : bool
- Determine if the browser is from a mobile device or not.
- isRobot() : bool
- Determine if the browser is a robot (Googlebot, Bingbot, Yahoo! Slurp...) or not.
- removeCustomBrowserDetection() : bool
- Remove support for a previously added Web browser.
- removeCustomPlatformDetection() : bool
- Remove support for a previously added platform.
- removeCustomRobotDetection() : bool
- Remove support for a previously added robot.
- setUserAgent() : mixed
- Set the user agent to use with the class.
- androidVerToStr() : string
- Convert the Android version numbers to the operating system name. For instance '1.6' returns 'Donut'.
- checkBrowser() : bool
- Determine what is the browser used by the user.
- checkBrowserAndroid() : bool
- Determine if the browser is the Android browser (based on the WebKit layout engine and coupled with Chrome's JavaScript engine) or not.
- checkBrowserBlackBerry() : bool
- Determine if the browser is the BlackBerry browser or not.
- checkBrowserChrome() : bool
- Determine if the browser is Chrome or not.
- checkBrowserCustom() : bool
- Determine if the browser is among the custom browser rules or not. Rules are checked in the order they were added.
- checkBrowserEdge() : bool
- Determine if the browser is Edge or not.
- checkBrowserFirebird() : bool
- Determine if the browser is Firebird or not. Firebird was the name of Firefox from version 0.6 to 0.7.1.
- checkBrowserFirefox() : bool
- Determine if the browser is Firefox or not.
- checkBrowserIcab() : bool
- Determine if the browser is iCab or not.
- checkBrowserIceCat() : bool
- Determine if the browser is GNU IceCat (formerly known as GNU IceWeasel) or not.
- checkBrowserIceWeasel() : bool
- Determine if the browser is GNU IceWeasel (now know as GNU IceCat) or not.
- checkBrowserInternetExplorer() : bool
- Determine if the browser is Internet Explorer or not.
- checkBrowserKonqueror() : bool
- Determine if the browser is Konqueror or not.
- checkBrowserLynx() : bool
- Determine if the browser is Lynx or not. It is the oldest web browser currently in general use and development.
- checkBrowserMozilla() : bool
- Determine if the browser is Mozilla or not.
- checkBrowserMsnTv() : bool
- Determine if the browser is MSN TV (formerly WebTV) or not.
- checkBrowserNetscape() : bool
- Determine if the browser is Netscape or not. Official support for this browser ended on March 1st, 2008.
- checkBrowserNokia() : bool
- Determine if the browser is a Nokia browser or not.
- checkBrowserOpera() : bool
- Determine if the browser is Opera or not.
- checkBrowserPhoenix() : bool
- Determine if the browser is Phoenix or not. Phoenix was the name of Firefox from version 0.1 to 0.5.
- checkBrowserSafari() : bool
- Determine if the browser is Safari or not.
- checkBrowserSamsung() : bool
- Determine if the browser is the Samsung Internet browser or not.
- checkBrowserUAWithVersion() : bool
- Test the user agent for a specific browser that use a "Version" string (like Safari and Opera). The user agent should look like: "Version/1.0 Browser name/123.456" or "Browser name/123.456 Version/1.0".
- checkBrowserUC() : bool
- Determine if the browser is UC Browser or not.
- checkPlatform() : mixed
- Determine the user's platform.
- checkPlatformCustom() : bool
- Determine if the platform is among the custom platform rules or not. Rules are checked in the order they were added.
- checkPlatformVersion() : mixed
- Determine the user's platform version.
- checkRobot() : mixed
- Determine if it's a robot crawling the page and find it's name and version.
- checkRobotBingbot() : bool
- Determine if the robot is the Bingbot crawler or not.
- checkRobotCustom() : bool
- Determine if the robot is among the custom robot rules or not. Rules are checked in the order they were added.
- checkRobotGooglebot() : bool
- Determine if the robot is the Googlebot crawler or not.
- checkRobotMsnBot() : bool
- Determine if the robot is the MSNBot crawler or not. In October 2010 it was replaced by the Bingbot robot.
- checkRobotSlurp() : bool
- Determine if the robot is the Yahoo! Slurp crawler or not.
- checkRobotW3CValidator() : bool
- Determine if the robot is the W3C Validator or not.
- checkRobotYahooMultimedia() : bool
- Determine if the robot is the Yahoo! multimedia crawler or not.
- checkSimpleBrowserUA() : bool
- Test the user agent for a specific browser where the browser name is immediately followed by the version number.
- checkSimpleRobot() : bool
- Test the user agent for a specific robot where the robot name is immediately followed by the version number.
- cleanVersion() : string
- Clean a version string from unwanted characters.
- containString() : bool
- Find if one or more substring is contained in a string.
- detect() : mixed
- Detect the user environment from the details in the user agent string.
- findAndGetVersion() : bool
- Test the user agent for a specific browser and extract it's version.
- iOSVerToStr() : string
- Convert the iOS version numbers to the operating system name. For instance '2.0' returns 'iPhone OS 2.0'.
- macVerToStr() : string
- Convert the macOS version numbers to the operating system name. For instance '10.7' returns 'Mac OS X Lion'.
- parseInt() : int
- Get the integer value of a string variable.
- reset() : mixed
- Reset all the properties of the class.
- safariBuildToSafariVer() : string
- Convert a Safari build number to a Safari version number.
- set64bit() : mixed
- Set if the browser is executed from a 64-bit platform.
- setBrowser() : mixed
- Set the name of the browser.
- setMobile() : mixed
- Set the browser to be from a mobile device or not.
- setPlatform() : mixed
- Set the platform on which the browser is on.
- setPlatformVersion() : mixed
- Set the platform version on which the browser is on.
- setRobot() : mixed
- Set the browser to be a robot (crawler) or not.
- setRobotName() : mixed
- Set the name of the robot.
- setRobotVersion() : mixed
- Set the version of the robot.
- setVersion() : mixed
- Set the version of the browser.
- webKitBuildToSafariVer() : string
- Convert a WebKit build number to a Safari version number.
- windowsNTVerToStr() : string
- Convert the Windows NT family version numbers to the operating system name. For instance '5.1' returns 'Windows XP'.
- windowsVerToStr() : string
- Convert the Windows 3.x & 9x family version numbers to the operating system name. For instance '4.10.1998' returns 'Windows 98'.
- wordPos() : mixed
- Find the position of the first occurrence of a word in a string.
Constants
BROWSER_ANDROID
public
mixed
BROWSER_ANDROID
= 'Android'
BROWSER_BLACKBERRY
public
mixed
BROWSER_BLACKBERRY
= 'BlackBerry'
BROWSER_CHROME
public
mixed
BROWSER_CHROME
= 'Chrome'
BROWSER_EDGE
public
mixed
BROWSER_EDGE
= 'Edge'
BROWSER_FIREBIRD
public
mixed
BROWSER_FIREBIRD
= 'Firebird'
BROWSER_FIREFOX
public
mixed
BROWSER_FIREFOX
= 'Firefox'
BROWSER_ICAB
public
mixed
BROWSER_ICAB
= 'iCab'
BROWSER_ICECAT
public
mixed
BROWSER_ICECAT
= 'GNU IceCat'
BROWSER_ICEWEASEL
public
mixed
BROWSER_ICEWEASEL
= 'GNU IceWeasel'
BROWSER_IE
public
mixed
BROWSER_IE
= 'Internet Explorer'
BROWSER_IE_MOBILE
public
mixed
BROWSER_IE_MOBILE
= 'Internet Explorer Mobile'
BROWSER_KONQUEROR
public
mixed
BROWSER_KONQUEROR
= 'Konqueror'
BROWSER_LYNX
public
mixed
BROWSER_LYNX
= 'Lynx'
BROWSER_MOZILLA
public
mixed
BROWSER_MOZILLA
= 'Mozilla'
BROWSER_MSNTV
public
mixed
BROWSER_MSNTV
= 'MSN TV'
BROWSER_NETSCAPE
public
mixed
BROWSER_NETSCAPE
= 'Netscape'
BROWSER_NOKIA
public
mixed
BROWSER_NOKIA
= 'Nokia Browser'
BROWSER_OPERA
public
mixed
BROWSER_OPERA
= 'Opera'
BROWSER_OPERA_MINI
public
mixed
BROWSER_OPERA_MINI
= 'Opera Mini'
BROWSER_OPERA_MOBILE
public
mixed
BROWSER_OPERA_MOBILE
= 'Opera Mobile'
BROWSER_PHOENIX
public
mixed
BROWSER_PHOENIX
= 'Phoenix'
BROWSER_SAFARI
public
mixed
BROWSER_SAFARI
= 'Safari'
BROWSER_SAMSUNG
public
mixed
BROWSER_SAMSUNG
= 'Samsung Internet'
BROWSER_TABLET_OS
public
mixed
BROWSER_TABLET_OS
= 'BlackBerry Tablet OS'
BROWSER_UC
public
mixed
BROWSER_UC
= 'UC Browser'
BROWSER_UNKNOWN
public
mixed
BROWSER_UNKNOWN
= 'unknown'
PLATFORM_ANDROID
public
mixed
PLATFORM_ANDROID
= 'Android'
PLATFORM_BLACKBERRY
public
mixed
PLATFORM_BLACKBERRY
= 'BlackBerry'
PLATFORM_CHROME_OS
public
mixed
PLATFORM_CHROME_OS
= 'Chrome OS'
PLATFORM_FREEBSD
public
mixed
PLATFORM_FREEBSD
= 'FreeBSD'
PLATFORM_IOS
public
mixed
PLATFORM_IOS
= 'iOS'
PLATFORM_LINUX
public
mixed
PLATFORM_LINUX
= 'Linux'
PLATFORM_MACINTOSH
public
mixed
PLATFORM_MACINTOSH
= 'Macintosh'
PLATFORM_NETBSD
public
mixed
PLATFORM_NETBSD
= 'NetBSD'
PLATFORM_NOKIA
public
mixed
PLATFORM_NOKIA
= 'Nokia'
PLATFORM_OPENBSD
public
mixed
PLATFORM_OPENBSD
= 'OpenBSD'
PLATFORM_OPENSOLARIS
public
mixed
PLATFORM_OPENSOLARIS
= 'OpenSolaris'
PLATFORM_SYMBIAN
public
mixed
PLATFORM_SYMBIAN
= 'Symbian'
PLATFORM_UNKNOWN
public
mixed
PLATFORM_UNKNOWN
= 'unknown'
PLATFORM_VERSION_UNKNOWN
public
mixed
PLATFORM_VERSION_UNKNOWN
= 'unknown'
PLATFORM_WINDOWS
public
mixed
PLATFORM_WINDOWS
= 'Windows'
PLATFORM_WINDOWS_CE
public
mixed
PLATFORM_WINDOWS_CE
= 'Windows CE'
PLATFORM_WINDOWS_PHONE
public
mixed
PLATFORM_WINDOWS_PHONE
= 'Windows Phone'
ROBOT_BINGBOT
public
mixed
ROBOT_BINGBOT
= 'Bingbot'
ROBOT_GOOGLEBOT
public
mixed
ROBOT_GOOGLEBOT
= 'Googlebot'
ROBOT_MSNBOT
public
mixed
ROBOT_MSNBOT
= 'MSNBot'
ROBOT_SLURP
public
mixed
ROBOT_SLURP
= 'Yahoo! Slurp'
ROBOT_UNKNOWN
public
mixed
ROBOT_UNKNOWN
= ''
ROBOT_VERSION_UNKNOWN
public
mixed
ROBOT_VERSION_UNKNOWN
= ''
ROBOT_W3CVALIDATOR
public
mixed
ROBOT_W3CVALIDATOR
= 'W3C Validator'
ROBOT_YAHOO_MM
public
mixed
ROBOT_YAHOO_MM
= 'Yahoo! Multimedia'
VERSION_UNKNOWN
Version unknown constant.
public
mixed
VERSION_UNKNOWN
= 'unknown'
Properties
$_agent
private
string
$_agent
= ''
Tags
$_browserName
private
string
$_browserName
= ''
Tags
$_compatibilityViewName
private
string
$_compatibilityViewName
= ''
Tags
$_compatibilityViewVer
private
string
$_compatibilityViewVer
= ''
Tags
$_customBrowserDetection
private
array<string|int, mixed>
$_customBrowserDetection
= array()
Tags
$_customPlatformDetection
private
array<string|int, mixed>
$_customPlatformDetection
= array()
Tags
$_customRobotDetection
private
array<string|int, mixed>
$_customRobotDetection
= array()
Tags
$_is64bit
private
bool
$_is64bit
= false
Tags
$_isMobile
private
bool
$_isMobile
= false
Tags
$_isRobot
private
bool
$_isRobot
= false
Tags
$_platform
private
string
$_platform
= ''
Tags
$_platformVersion
private
string
$_platformVersion
= ''
Tags
$_robotName
private
string
$_robotName
= ''
Tags
$_robotVersion
private
string
$_robotVersion
= ''
Tags
$_version
private
string
$_version
= ''
Tags
Methods
__construct()
BrowserDetection class constructor.
public
__construct([string $useragent = '' ]) : mixed
Parameters
- $useragent : string = ''
-
(optional) The user agent to work with. Leave empty for the current user agent (contained in $_SERVER['HTTP_USER_AGENT']).
__toString()
Determine how the class will react when it is treated like a string.
public
__toString() : string
Return values
string —Returns an HTML formatted string with a summary of the browser informations.
addCustomBrowserDetection()
Dynamically add support for a new Web browser.
public
addCustomBrowserDetection(string $browserName[, mixed $uaNameToLookFor = '' ][, bool $isMobile = false ][, string $separator = '/' ][, bool $uaNameFindWords = true ]) : bool
Parameters
- $browserName : string
-
The Web browser name (used for display).
- $uaNameToLookFor : mixed = ''
-
(optional) The string (or array of strings) representing the browser name to find in the user agent. If omitted, $browserName will be used.
- $isMobile : bool = false
-
(optional) Determines if the browser is from a mobile device.
- $separator : string = '/'
-
(optional) The separator string used to split the browser name and the version number in the user agent.
- $uaNameFindWords : bool = true
-
(optional) Determines if the browser name to find should match a word instead of a part of a word. For example "Bar" would not be found in "FooBar" when true but would be found in "Foo Bar". When set to false, the browser name can be found anywhere in the user agent string.
Tags
Return values
bool —Returns true if the custom rule has been added, false otherwise.
addCustomPlatformDetection()
Dynamically add support for a new platform.
public
addCustomPlatformDetection(string $platformName[, mixed $platformNameToLookFor = '' ][, bool $isMobile = false ][, bool $uaNameFindWords = true ]) : bool
Parameters
- $platformName : string
-
The platform name (used for display).
- $platformNameToLookFor : mixed = ''
-
(optional) The string (or array of strings) representing the platform name to find in the user agent. If omitted, $platformName will be used.
- $isMobile : bool = false
-
(optional) Determines if the platform is from a mobile device.
- $uaNameFindWords : bool = true
-
(optional) Determines if the platform name to find should match a word instead of a part of a word. For example "Bar" would not be found in "FooBar" when true but would be found in "Foo Bar".
Tags
Return values
bool —Returns true if the custom rule has been added, false otherwise.
addCustomRobotDetection()
Dynamically add support for a new robot.
public
addCustomRobotDetection(string $robotName[, mixed $uaNameToLookFor = '' ][, bool $isMobile = false ][, string $separator = '/' ][, bool $uaNameFindWords = true ]) : bool
Parameters
- $robotName : string
-
The robot name (used for display).
- $uaNameToLookFor : mixed = ''
-
(optional) The string (or array of strings) representing the robot name to find in the user agent. If omitted, $robotName will be used.
- $isMobile : bool = false
-
(optional) Determines if the robot should be considered as mobile or not.
- $separator : string = '/'
-
(optional) The separator string used to split the robot name and the version number in the user agent.
- $uaNameFindWords : bool = true
-
(optional) Determines if the robot name to find should match a word instead of a part of a word. For example "Bar" would not be found in "FooBar" when true but would be found in "Foo Bar". When set to false, the robot name can be found anywhere in the user agent string.
Tags
Return values
bool —Returns true if the custom rule has been added, false otherwise.
compareVersions()
Compare two version number strings.
public
compareVersions(string $sourceVer, string $compareVer) : int
Parameters
- $sourceVer : string
-
The source version number.
- $compareVer : string
-
The version number to compare with the source version number.
Return values
int —Returns -1 if $sourceVer < $compareVer, 0 if $sourceVer == $compareVer or 1 if $sourceVer > $compareVer.
getIECompatibilityView()
Get the name and version of the browser emulated in the compatibility view mode (if any). Since Internet Explorer 8, IE can be put in compatibility mode to make websites that were created for older browsers, especially IE 6 and 7, look better in IE 8+ which renders web pages closer to the standards and thus differently from those older versions of IE.
public
getIECompatibilityView([bool $asArray = false ]) : mixed
Parameters
- $asArray : bool = false
-
(optional) Determines if the return value must be an array (true) or a string (false).
Return values
mixed —If a string was requested, the function returns the name and version of the browser emulated in the compatibility view mode or an empty string if the browser is not in compatibility view mode. If an array was requested, an array with the keys 'browser' and 'version' is returned.
getLibVersion()
Return the BrowserDetection class version.
public
getLibVersion() : string
Return values
string —Returns the version as a sting with the #.#.# format.
getName()
Get the name of the browser. All of the return values are class constants. You can compare them like this: $myBrowserInstance->getName() == BrowserDetection::BROWSER_FIREFOX.
public
getName() : string
Return values
string —Returns the name of the browser or BrowserDetection::BROWSER_UNKNOWN if unknown.
getPlatform()
Get the name of the platform family on which the browser is run on (such as Windows, Apple, etc.). All of the return values are class constants. You can compare them like this: $myBrowserInstance->getPlatform() == BrowserDetection::PLATFORM_ANDROID.
public
getPlatform() : string
Return values
string —Returns the name of the platform or BrowserDetection::PLATFORM_UNKNOWN if unknown.
getPlatformVersion()
Get the platform version on which the browser is run on. It can be returned as a string number like 'NT 6.3' or as a name like 'Windows 8.1'. When returning version string numbers for Windows NT OS families the number is prefixed by 'NT ' to differentiate from older Windows 3.x & 9x release. At the moment only the Windows and Android operating systems are supported.
public
getPlatformVersion([bool $returnVersionNumbers = false ][, bool $returnServerFlavor = false ]) : string
Parameters
- $returnVersionNumbers : bool = false
-
(optional) Determines if the return value must be versions numbers as a string (true) or the version name (false).
- $returnServerFlavor : bool = false
-
(optional) Since some Windows NT versions have the same values, this flag determines if the Server flavor is returned or not. For instance Windows 8.1 and Windows Server 2012 R2 both use version 6.3. This parameter is only useful when testing for Windows.
Return values
string —Returns the version name/version numbers of the platform or the constant PLATFORM_VERSION_UNKNOWN if unknown.
getRobotName()
Get the name of the robot. All of the return values are class constants. You can compare them like this: $myBrowserInstance->getRobotName() == BrowserDetection::ROBOT_GOOGLEBOT.
public
getRobotName() : string
Return values
string —Returns the name of the robot or BrowserDetection::ROBOT_UNKNOWN if unknown.
getRobotVersion()
Get the version of the robot.
public
getRobotVersion() : string
Return values
string —Returns the version of the robot or BrowserDetection::ROBOT_VERSION_UNKNOWN if unknown.
getUserAgent()
Get the user agent value used by the class to determine the browser details.
public
getUserAgent() : string
Return values
string —The user agent string.
getVersion()
Get the version of the browser.
public
getVersion() : string
Return values
string —Returns the version of the browser or BrowserDetection::VERSION_UNKNOWN if unknown.
is64bitPlatform()
Determine if the browser is executed from a 64-bit platform. Keep in mind that not all platforms/browsers report this and the result may not always be accurate.
public
is64bitPlatform() : bool
Return values
bool —Returns true if the browser is executed from a 64-bit platform.
isChromeFrame()
Determine if the browser runs Google Chrome Frame (it's a plug-in designed for Internet Explorer 6+ based on the open-source Chromium project - it's like a Chrome browser within IE).
public
isChromeFrame() : bool
Return values
bool —Returns true if the browser is using Google Chrome Frame, false otherwise.
isInIECompatibilityView()
Determine if the browser is in compatibility view or not. Since Internet Explorer 8, IE can be put in compatibility mode to make websites that were created for older browsers, especially IE 6 and 7, look better in IE 8+ which renders web pages closer to the standards and thus differently from those older versions of IE.
public
isInIECompatibilityView() : bool
Return values
bool —Returns true if the browser is in compatibility view, false otherwise.
isMobile()
Determine if the browser is from a mobile device or not.
public
isMobile() : bool
Return values
bool —Returns true if the browser is from a mobile device, false otherwise.
isRobot()
Determine if the browser is a robot (Googlebot, Bingbot, Yahoo! Slurp...) or not.
public
isRobot() : bool
Return values
bool —Returns true if the browser is a robot, false otherwise.
removeCustomBrowserDetection()
Remove support for a previously added Web browser.
public
removeCustomBrowserDetection(string $browserName) : bool
Parameters
- $browserName : string
-
The Web browser name as used when added.
Tags
Return values
bool —Returns true if the custom rule has been found and removed, false otherwise.
removeCustomPlatformDetection()
Remove support for a previously added platform.
public
removeCustomPlatformDetection(string $platformName) : bool
Parameters
- $platformName : string
-
The platform name as used when added.
Tags
Return values
bool —Returns true if the custom rule has been found and removed, false otherwise.
removeCustomRobotDetection()
Remove support for a previously added robot.
public
removeCustomRobotDetection(string $robotName) : bool
Parameters
- $robotName : string
-
The robot name as used when added.
Tags
Return values
bool —Returns true if the custom rule has been found and removed, false otherwise.
setUserAgent()
Set the user agent to use with the class.
public
setUserAgent([string $agentString = '' ]) : mixed
Parameters
- $agentString : string = ''
-
(optional) The value of the user agent. If an empty string is sent (default), $_SERVER['HTTP_USER_AGENT'] will be used.
androidVerToStr()
Convert the Android version numbers to the operating system name. For instance '1.6' returns 'Donut'.
protected
androidVerToStr(string $androidVer) : string
Parameters
- $androidVer : string
-
The Android version numbers as a string.
Tags
Return values
string —The operating system name or the constant PLATFORM_VERSION_UNKNOWN if nothing match the version numbers.
checkBrowser()
Determine what is the browser used by the user.
protected
checkBrowser() : bool
Tags
Return values
bool —Returns true if the browser has been identified, false otherwise.
checkBrowserAndroid()
Determine if the browser is the Android browser (based on the WebKit layout engine and coupled with Chrome's JavaScript engine) or not.
protected
checkBrowserAndroid() : bool
Tags
Return values
bool —Returns true if the browser is the Android browser, false otherwise.
checkBrowserBlackBerry()
Determine if the browser is the BlackBerry browser or not.
protected
checkBrowserBlackBerry() : bool
Tags
Return values
bool —Returns true if the browser is the BlackBerry browser, false otherwise.
checkBrowserChrome()
Determine if the browser is Chrome or not.
protected
checkBrowserChrome() : bool
Tags
Return values
bool —Returns true if the browser is Chrome, false otherwise.
checkBrowserCustom()
Determine if the browser is among the custom browser rules or not. Rules are checked in the order they were added.
protected
checkBrowserCustom() : bool
Tags
Return values
bool —Returns true if we found the browser we were looking for in the custom rules, false otherwise.
checkBrowserEdge()
Determine if the browser is Edge or not.
protected
checkBrowserEdge() : bool
Tags
Return values
bool —Returns true if the browser is Edge, false otherwise.
checkBrowserFirebird()
Determine if the browser is Firebird or not. Firebird was the name of Firefox from version 0.6 to 0.7.1.
protected
checkBrowserFirebird() : bool
Tags
Return values
bool —Returns true if the browser is Firebird, false otherwise.
checkBrowserFirefox()
Determine if the browser is Firefox or not.
protected
checkBrowserFirefox() : bool
Tags
Return values
bool —Returns true if the browser is Firefox, false otherwise.
checkBrowserIcab()
Determine if the browser is iCab or not.
protected
checkBrowserIcab() : bool
Tags
Return values
bool —Returns true if the browser is iCab, false otherwise.
checkBrowserIceCat()
Determine if the browser is GNU IceCat (formerly known as GNU IceWeasel) or not.
protected
checkBrowserIceCat() : bool
Tags
Return values
bool —Returns true if the browser is GNU IceCat, false otherwise.
checkBrowserIceWeasel()
Determine if the browser is GNU IceWeasel (now know as GNU IceCat) or not.
protected
checkBrowserIceWeasel() : bool
Tags
Return values
bool —Returns true if the browser is GNU IceWeasel, false otherwise.
checkBrowserInternetExplorer()
Determine if the browser is Internet Explorer or not.
protected
checkBrowserInternetExplorer() : bool
Tags
Return values
bool —Returns true if the browser is Internet Explorer, false otherwise.
checkBrowserKonqueror()
Determine if the browser is Konqueror or not.
protected
checkBrowserKonqueror() : bool
Tags
Return values
bool —Returns true if the browser is Konqueror, false otherwise.
checkBrowserLynx()
Determine if the browser is Lynx or not. It is the oldest web browser currently in general use and development.
protected
checkBrowserLynx() : bool
It is a text-based only Web browser.
Tags
Return values
bool —Returns true if the browser is Lynx, false otherwise.
checkBrowserMozilla()
Determine if the browser is Mozilla or not.
protected
checkBrowserMozilla() : bool
Tags
Return values
bool —Returns true if the browser is Mozilla, false otherwise.
checkBrowserMsnTv()
Determine if the browser is MSN TV (formerly WebTV) or not.
protected
checkBrowserMsnTv() : bool
Tags
Return values
bool —Returns true if the browser is WebTv, false otherwise.
checkBrowserNetscape()
Determine if the browser is Netscape or not. Official support for this browser ended on March 1st, 2008.
protected
checkBrowserNetscape() : bool
Tags
Return values
bool —Returns true if the browser is Netscape, false otherwise.
checkBrowserNokia()
Determine if the browser is a Nokia browser or not.
protected
checkBrowserNokia() : bool
Tags
Return values
bool —Returns true if the browser is a Nokia browser, false otherwise.
checkBrowserOpera()
Determine if the browser is Opera or not.
protected
checkBrowserOpera() : bool
Tags
Return values
bool —Returns true if the browser is Opera, false otherwise.
checkBrowserPhoenix()
Determine if the browser is Phoenix or not. Phoenix was the name of Firefox from version 0.1 to 0.5.
protected
checkBrowserPhoenix() : bool
Tags
Return values
bool —Returns true if the browser is Phoenix, false otherwise.
checkBrowserSafari()
Determine if the browser is Safari or not.
protected
checkBrowserSafari() : bool
Tags
Return values
bool —Returns true if the browser is Safari, false otherwise.
checkBrowserSamsung()
Determine if the browser is the Samsung Internet browser or not.
protected
checkBrowserSamsung() : bool
Tags
Return values
bool —Returns true if the browser is the the Samsung Internet browser, false otherwise.
checkBrowserUAWithVersion()
Test the user agent for a specific browser that use a "Version" string (like Safari and Opera). The user agent should look like: "Version/1.0 Browser name/123.456" or "Browser name/123.456 Version/1.0".
protected
checkBrowserUAWithVersion(mixed $uaNameToLookFor, string $userAgent, string $browserName[, bool $isMobile = false ][, bool $findWords = true ]) : bool
Parameters
- $uaNameToLookFor : mixed
-
The string (or array of strings) representing the browser name to find in the user agent.
- $userAgent : string
-
The user agent string to work with.
- $browserName : string
-
The literal browser name. Always use a class constant!
- $isMobile : bool = false
-
(optional) Determines if the browser is from a mobile device.
- $findWords : bool = true
-
(optional) Determines if the needle should match a word to be found. For example "Bar" would not be found in "FooBar" when true but would be found in "Foo Bar". When set to false, the needle can be found anywhere in the haystack.
Tags
Return values
bool —Returns true if we found the browser we were looking for, false otherwise.
checkBrowserUC()
Determine if the browser is UC Browser or not.
protected
checkBrowserUC() : bool
Tags
Return values
bool —Returns true if the browser is UC Browser, false otherwise.
checkPlatform()
Determine the user's platform.
protected
checkPlatform() : mixed
Tags
checkPlatformCustom()
Determine if the platform is among the custom platform rules or not. Rules are checked in the order they were added.
protected
checkPlatformCustom() : bool
Tags
Return values
bool —Returns true if we found the platform we were looking for in the custom rules, false otherwise.
checkPlatformVersion()
Determine the user's platform version.
protected
checkPlatformVersion() : mixed
Tags
checkRobot()
Determine if it's a robot crawling the page and find it's name and version.
protected
checkRobot() : mixed
Tags
checkRobotBingbot()
Determine if the robot is the Bingbot crawler or not.
protected
checkRobotBingbot() : bool
Tags
Return values
bool —Returns true if the robot is Bingbot, false otherwise.
checkRobotCustom()
Determine if the robot is among the custom robot rules or not. Rules are checked in the order they were added.
protected
checkRobotCustom() : bool
Tags
Return values
bool —Returns true if we found the robot we were looking for in the custom rules, false otherwise.
checkRobotGooglebot()
Determine if the robot is the Googlebot crawler or not.
protected
checkRobotGooglebot() : bool
Tags
Return values
bool —Returns true if the robot is Googlebot, false otherwise.
checkRobotMsnBot()
Determine if the robot is the MSNBot crawler or not. In October 2010 it was replaced by the Bingbot robot.
protected
checkRobotMsnBot() : bool
Tags
Return values
bool —Returns true if the robot is MSNBot, false otherwise.
checkRobotSlurp()
Determine if the robot is the Yahoo! Slurp crawler or not.
protected
checkRobotSlurp() : bool
Tags
Return values
bool —Returns true if the robot is Yahoo! Slurp, false otherwise.
checkRobotW3CValidator()
Determine if the robot is the W3C Validator or not.
protected
checkRobotW3CValidator() : bool
Tags
Return values
bool —Returns true if the robot is the W3C Validator, false otherwise.
checkRobotYahooMultimedia()
Determine if the robot is the Yahoo! multimedia crawler or not.
protected
checkRobotYahooMultimedia() : bool
Tags
Return values
bool —Returns true if the robot is the Yahoo! multimedia crawler, false otherwise.
checkSimpleBrowserUA()
Test the user agent for a specific browser where the browser name is immediately followed by the version number.
protected
checkSimpleBrowserUA(mixed $uaNameToLookFor, string $userAgent, string $browserName[, bool $isMobile = false ][, string $separator = '/' ][, bool $uaNameFindWords = true ]) : bool
The user agent should look like: "Browser name/1.0" or "Browser 1.0;".
Parameters
- $uaNameToLookFor : mixed
-
The string (or array of strings) representing the browser name to find in the user agent.
- $userAgent : string
-
The user agent string to work with.
- $browserName : string
-
The literal browser name. Always use a class constant!
- $isMobile : bool = false
-
(optional) Determines if the browser is from a mobile device.
- $separator : string = '/'
-
(optional) The separator string used to split the browser name and the version number in the user agent.
- $uaNameFindWords : bool = true
-
(optional) Determines if the browser name to find should match a word instead of a part of a word. For example "Bar" would not be found in "FooBar" when true but would be found in "Foo Bar". When set to false, the browser name can be found anywhere in the user agent string.
Tags
Return values
bool —Returns true if we found the browser we were looking for, false otherwise.
checkSimpleRobot()
Test the user agent for a specific robot where the robot name is immediately followed by the version number.
protected
checkSimpleRobot(mixed $uaNameToLookFor, string $userAgent, string $robotName[, string $separator = '/' ][, bool $uaNameFindWords = true ]) : bool
The user agent should look like: "Robot name/1.0" or "Robot 1.0;".
Parameters
- $uaNameToLookFor : mixed
-
The string (or array of strings) representing the robot name to find in the user agent.
- $userAgent : string
-
The user agent string to work with.
- $robotName : string
-
The literal robot name. Always use a class constant!
- $separator : string = '/'
-
(optional) The separator string used to split the robot name and the version number in the user agent.
- $uaNameFindWords : bool = true
-
(optional) Determines if the robot name to find should match a word instead of a part of a word. For example "Bar" would not be found in "FooBar" when true but would be found in "Foo Bar". When set to false, the robot name can be found anywhere in the user agent string.
Tags
Return values
bool —Returns true if we found the robot we were looking for, false otherwise.
cleanVersion()
Clean a version string from unwanted characters.
protected
cleanVersion(string $version[, mixed $toRemove = NULL ]) : string
Parameters
- $version : string
-
The version string to clean.
- $toRemove : mixed = NULL
-
(optional) String or array of strings representing additional string(s) to remove.
Tags
Return values
string —Returns the cleaned version number string.
containString()
Find if one or more substring is contained in a string.
protected
containString(string $haystack, mixed $needle[, bool $insensitive = true ][, bool $findWords = true ][, int &$foundPos = NULL ]) : bool
Parameters
- $haystack : string
-
The string to search in.
- $needle : mixed
-
The string to search for. Can be a string or an array of strings if multiples values are to be searched.
- $insensitive : bool = true
-
(optional) Determines if we do a case-sensitive search (false) or a case-insensitive one (true).
- $findWords : bool = true
-
(optional) Determines if the needle should match a word to be found. For example "Bar" would not be found in "FooBar" when true but would be found in "Foo Bar". When set to false, the needle can be found anywhere in the haystack.
- $foundPos : int = NULL
-
(optional) Integer buffer that will contain the position of the needle (if found and if a non NULL variable has been passed).
Tags
Return values
bool —Returns true if the needle (or one of the needles) has been found in the haystack, false otherwise.
detect()
Detect the user environment from the details in the user agent string.
protected
detect() : mixed
Tags
findAndGetVersion()
Test the user agent for a specific browser and extract it's version.
protected
findAndGetVersion(type $uaNameToLookFor, type $userAgent, type &$version[, type $separator = '/' ][, type $uaNameFindWords = true ]) : bool
Parameters
- $uaNameToLookFor : type
-
The string (or array of strings) representing the browser name to find in the user agent.
- $userAgent : type
-
The user agent string to work with.
- $version : type
-
String buffer that will contain the version found (if any).
- $separator : type = '/'
-
(optional) The separator string used to split the browser name and the version number in the user agent.
- $uaNameFindWords : type = true
-
(optional) Determines if the browser name to find should match a word instead of a part of a word. For example "Bar" would not be found in "FooBar" when true but would be found in "Foo Bar". When set to false, the browser name can be found anywhere in the user agent string.
Tags
Return values
bool —Returns true if we found the browser we were looking for, false otherwise.
iOSVerToStr()
Convert the iOS version numbers to the operating system name. For instance '2.0' returns 'iPhone OS 2.0'.
protected
iOSVerToStr(string $iOSVer) : string
Parameters
- $iOSVer : string
-
The iOS version numbers as a string.
Tags
Return values
string —The operating system name.
macVerToStr()
Convert the macOS version numbers to the operating system name. For instance '10.7' returns 'Mac OS X Lion'.
protected
macVerToStr(string $macVer) : string
Firefox, Safari and Chromium development teams have discovered a long tail of websites broken when reporting "Mac OS X 11" in the user agent string. In order to slightly improve user privacy as well as Web compatibility, they all capped the reported macOS version to 10.15 (Catalina) in the user agent string.
Firefox reported macOS version is capped at 10.15 since Firefox 87 (March 23, 2021). This change has been also backported in Firefox 78.9.0esr (March 23, 2021).
Safari reported macOS version is capped at 10.15.7 since Safari 14.1 (April 26, 2021).
Chromium reported macOS version is capped at 10.15.7 since Chromium 91.0.4437.0 (May 25, 2021).
See below links for more details.
Parameters
- $macVer : string
-
The macOS version numbers as a string.
Tags
Return values
string —The operating system name or the constant PLATFORM_VERSION_UNKNOWN if nothing match the version numbers.
parseInt()
Get the integer value of a string variable.
protected
parseInt(string $intStr) : int
Parameters
- $intStr : string
-
The scalar value being converted to an integer.
Tags
Return values
int —The integer value of $intStr on success, or 0 on failure.
reset()
Reset all the properties of the class.
protected
reset() : mixed
Tags
safariBuildToSafariVer()
Convert a Safari build number to a Safari version number.
protected
safariBuildToSafariVer(string $version) : string
Parameters
- $version : string
-
A string representing the version number.
Tags
Return values
string —Returns the Safari version string. If the version can't be determined, an empty string is returned.
set64bit()
Set if the browser is executed from a 64-bit platform.
protected
set64bit(bool $is64bit) : mixed
Parameters
- $is64bit : bool
-
Value that tells if the browser is executed from a 64-bit platform.
Tags
setBrowser()
Set the name of the browser.
protected
setBrowser(string $browserName) : mixed
Parameters
- $browserName : string
-
The name of the browser.
Tags
setMobile()
Set the browser to be from a mobile device or not.
protected
setMobile([bool $isMobile = true ]) : mixed
Parameters
- $isMobile : bool = true
-
(optional) Value that tells if the browser is on a mobile device or not.
Tags
setPlatform()
Set the platform on which the browser is on.
protected
setPlatform(string $platform) : mixed
Parameters
- $platform : string
-
The name of the platform.
Tags
setPlatformVersion()
Set the platform version on which the browser is on.
protected
setPlatformVersion(string $platformVer) : mixed
Parameters
- $platformVer : string
-
The version numbers of the platform.
Tags
setRobot()
Set the browser to be a robot (crawler) or not.
protected
setRobot([bool $isRobot = true ]) : mixed
Parameters
- $isRobot : bool = true
-
(optional) Value that tells if the browser is a robot or not.
Tags
setRobotName()
Set the name of the robot.
protected
setRobotName(string $robotName) : mixed
Parameters
- $robotName : string
-
The name of the robot.
Tags
setRobotVersion()
Set the version of the robot.
protected
setRobotVersion(string $robotVersion) : mixed
Parameters
- $robotVersion : string
-
The version of the robot.
Tags
setVersion()
Set the version of the browser.
protected
setVersion(string $version) : mixed
Parameters
- $version : string
-
The version of the browser.
Tags
webKitBuildToSafariVer()
Convert a WebKit build number to a Safari version number.
protected
webKitBuildToSafariVer(string $version) : string
Parameters
- $version : string
-
A string representing the version number.
Tags
Return values
string —Returns the Safari version string. If the version can't be determined, an empty string is returned.
windowsNTVerToStr()
Convert the Windows NT family version numbers to the operating system name. For instance '5.1' returns 'Windows XP'.
protected
windowsNTVerToStr(string $winVer[, bool $returnServerFlavor = false ]) : string
Windows 10 and Windows 11 share the same major version number (10). Windows 11 starts with build 22000 (version 10.0.22000) but the build is not included in the UA.
Windows Server 2022, 2019 & 2016 have also the same version number (10). Again, only the build can differentiate these versions.
Parameters
- $winVer : string
-
The Windows NT family version numbers as a string.
- $returnServerFlavor : bool = false
-
(optional) Since some Windows NT versions have the same values, this flag determines if the Server flavor is returned or not. For instance Windows 8.1 and Windows Server 2012 R2 both use version 6.3.
Tags
Return values
string —The operating system name or the constant PLATFORM_VERSION_UNKNOWN if nothing match the version numbers.
windowsVerToStr()
Convert the Windows 3.x & 9x family version numbers to the operating system name. For instance '4.10.1998' returns 'Windows 98'.
protected
windowsVerToStr(string $winVer) : string
Parameters
- $winVer : string
-
The Windows 3.x or 9x family version numbers as a string.
Tags
Return values
string —The operating system name or the constant PLATFORM_VERSION_UNKNOWN if nothing match the version numbers.
wordPos()
Find the position of the first occurrence of a word in a string.
protected
wordPos(string $haystack, string $needle[, bool $insensitive = true ][, int $offset = 0 ][, string &$foundString = NULL ]) : mixed
Parameters
- $haystack : string
-
The string to search in.
- $needle : string
-
The string to search for.
- $insensitive : bool = true
-
(optional) Determines if we do a case-sensitive search (false) or a case-insensitive one (true).
- $offset : int = 0
-
If specified, search will start this number of characters counted from the beginning of the string. If the offset is negative, the search will start this number of characters counted from the end of the string.
- $foundString : string = NULL
-
String buffer that will contain the exact matching needle found. Set to NULL when return value of the function is false.
Tags
Return values
mixed —Returns the position of the needle (int) if found, false otherwise. Warning this function may return Boolean false, but may also return a non-Boolean value which evaluates to false.