Browser_Detection

# Class: BrowserDetection Source Location: /BrowserDetection.php
### Class Overview
The BrowserDetection class facilitates the identification of the user's environment such as Web browser, version, platform and device type. #### Author(s): Alexandre Valiquette, Chris Schuld, Gary White #### Version: 2.9.7 #### Copyright: Copyright (c) 2022, Wolfcast | ### Variables $_agent $_browserName $_compatibilityViewName $_compatibilityViewVer $_customBrowserDetection $_customPlatformDetection $_customRobotDetection $_is64bit $_isMobile $_isRobot $_platform $_platformVersion $_robotName $_robotVersion $_version | ### Constants BROWSER_ANDROID BROWSER_BLACKBERRY BROWSER_CHROME BROWSER_EDGE BROWSER_FIREBIRD BROWSER_FIREFOX BROWSER_ICAB BROWSER_ICECAT BROWSER_ICEWEASEL BROWSER_IE BROWSER_IE_MOBILE BROWSER_KONQUEROR BROWSER_LYNX BROWSER_MOZILLA BROWSER_MSNTV BROWSER_NETSCAPE BROWSER_NOKIA BROWSER_OPERA BROWSER_OPERA_MINI BROWSER_OPERA_MOBILE BROWSER_PHOENIX BROWSER_SAFARI BROWSER_SAMSUNG BROWSER_TABLET_OS BROWSER_UC BROWSER_UNKNOWN PLATFORM_ANDROID PLATFORM_BLACKBERRY PLATFORM_CHROME_OS PLATFORM_FREEBSD PLATFORM_IOS PLATFORM_LINUX PLATFORM_MACINTOSH PLATFORM_NETBSD PLATFORM_NOKIA PLATFORM_OPENBSD PLATFORM_OPENSOLARIS PLATFORM_SYMBIAN PLATFORM_UNKNOWN PLATFORM_VERSION_UNKNOWN PLATFORM_WINDOWS PLATFORM_WINDOWS_CE PLATFORM_WINDOWS_PHONE ROBOT_BINGBOT ROBOT_GOOGLEBOT ROBOT_MSNBOT ROBOT_SLURP ROBOT_UNKNOWN ROBOT_VERSION_UNKNOWN ROBOT_W3CVALIDATOR ROBOT_YAHOO_MM VERSION_UNKNOWN | ### Methods __construct addCustomBrowserDetection addCustomPlatformDetection addCustomRobotDetection androidVerToStr checkBrowser checkBrowserAndroid checkBrowserBlackBerry checkBrowserChrome checkBrowserCustom checkBrowserEdge checkBrowserFirebird checkBrowserFirefox checkBrowserIcab checkBrowserIceCat checkBrowserIceWeasel checkBrowserInternetExplorer checkBrowserKonqueror checkBrowserLynx checkBrowserMozilla checkBrowserMsnTv checkBrowserNetscape checkBrowserNokia checkBrowserOpera checkBrowserPhoenix checkBrowserSafari checkBrowserSamsung checkBrowserUAWithVersion checkBrowserUC checkPlatform checkPlatformCustom checkPlatformVersion checkRobot checkRobotBingbot checkRobotCustom checkRobotGooglebot checkRobotMsnBot checkRobotSlurp checkRobotW3CValidator checkRobotYahooMultimedia checkSimpleBrowserUA checkSimpleRobot cleanVersion compareVersions containString detect findAndGetVersion getIECompatibilityView getLibVersion getName getPlatform getPlatformVersion getRobotName getRobotVersion getUserAgent getVersion iOSVerToStr is64bitPlatform isChromeFrame isInIECompatibilityView isMobile isRobot macVerToStr parseInt removeCustomBrowserDetection removeCustomPlatformDetection removeCustomRobotDetection reset safariBuildToSafariVer set64bit setBrowser setMobile setPlatform setPlatformVersion setRobot setRobotName setRobotVersion setUserAgent setVersion webKitBuildToSafariVer windowsNTVerToStr windowsVerToStr wordPos __toString
### Class Details [line 158] 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: 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:
author: | Alexandre Valiquette, Chris Schuld, Gary White
version: | 2.9.7
copyright: | Copyright (c) 2022, Wolfcast
link: | https://wolfcast.com/open-source/browser-detection/tutorial.php
link: | https://wolfcast.com/
link: | https://www.apptools.com/phptools/browser/
link: | https://chrisschuld.com/
last-modified: | September 20, 2022
license: | https://spdx.org/licenses/MIT.html
license: | https://spdx.org/licenses/GPL-3.0-only.html
[ Top ] ### Class Variables #### $_agent = '' [line 237] #### Tags:
access: | private
Type: | string
[ Top ] #### $_browserName = '' [line 243] #### Tags:
access: | private
Type: | string
[ Top ] #### $_compatibilityViewName = '' [line 249] #### Tags:
access: | private
Type: | string
[ Top ] #### $_compatibilityViewVer = '' [line 255] #### Tags:
access: | private
Type: | string
[ Top ] #### $_customBrowserDetection = array() [line 261] #### Tags:
access: | private
Type: | array
[ Top ] #### $_customPlatformDetection = array() [line 267] #### Tags:
access: | private
Type: | array
[ Top ] #### $_customRobotDetection = array() [line 273] #### Tags:
access: | private
Type: | array
[ Top ] #### $_is64bit = false [line 279] #### Tags:
access: | private
Type: | boolean
[ Top ] #### $_isMobile = false [line 285] #### Tags:
access: | private
Type: | boolean
[ Top ] #### $_isRobot = false [line 291] #### Tags:
access: | private
Type: | boolean
[ Top ] #### $_platform = '' [line 297] #### Tags:
access: | private
Type: | string
[ Top ] #### $_platformVersion = '' [line 303] #### Tags:
access: | private
Type: | string
[ Top ] #### $_robotName = '' [line 309] #### Tags:
access: | private
Type: | string
[ Top ] #### $_robotVersion = '' [line 315] #### Tags:
access: | private
Type: | string
[ Top ] #### $_version = '' [line 321] #### Tags:
access: | private
Type: | string
[ Top ] ### Class Methods ### constructor __construct [line 332]
`BrowserDetection __construct( [string $useragent = ''])`
BrowserDetection class constructor. #### Tags:
access: | public
#### Parameters:
string | $useragent | (optional) The user agent to work with. Leave empty for the current user agent (contained in $_SERVER['HTTP_USER_AGENT']).
[ Top ] ### method addCustomBrowserDetection [line 386]
`boolean addCustomBrowserDetection( string $browserName, [mixed $uaNameToLookFor = ''], [boolean $isMobile = false], [string $separator = '/'], [boolean $uaNameFindWords = true])`
Dynamically add support for a new Web browser. #### Tags:
return: | Returns true if the custom rule has been added, false otherwise.
see: | BrowserDetection::removeCustomBrowserDetection()
access: | public
#### Parameters:
string | $browserName | The Web browser name (used for display).
mixed | $uaNameToLookFor | (optional) The string (or array of strings) representing the browser name to find in the user agent. If omitted, $browserName will be used.
boolean | $isMobile | (optional) Determines if the browser is from a mobile device.
string | $separator | (optional) The separator string used to split the browser name and the version number in the user agent.
boolean | $uaNameFindWords | (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.
[ Top ] ### method addCustomPlatformDetection [line 413]
`boolean addCustomPlatformDetection( string $platformName, [mixed $platformNameToLookFor = ''], [boolean $isMobile = false], [boolean $uaNameFindWords = true])`
Dynamically add support for a new platform. #### Tags:
return: | Returns true if the custom rule has been added, false otherwise.
see: | BrowserDetection::removeCustomPlatformDetection()
access: | public
#### Parameters:
string | $platformName | The platform name (used for display).
mixed | $platformNameToLookFor | (optional) The string (or array of strings) representing the platform name to find in the user agent. If omitted, $platformName will be used.
boolean | $isMobile | (optional) Determines if the platform is from a mobile device.
boolean | $uaNameFindWords | (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".
[ Top ] ### method addCustomRobotDetection [line 444]
`boolean addCustomRobotDetection( string $robotName, [mixed $uaNameToLookFor = ''], [boolean $isMobile = false], [string $separator = '/'], [boolean $uaNameFindWords = true])`
Dynamically add support for a new robot. #### Tags:
return: | Returns true if the custom rule has been added, false otherwise.
see: | BrowserDetection::removeCustomRobotDetection()
access: | public
#### Parameters:
string | $robotName | The robot name (used for display).
mixed | $uaNameToLookFor | (optional) The string (or array of strings) representing the robot name to find in the user agent. If omitted, $robotName will be used.
boolean | $isMobile | (optional) Determines if the robot should be considered as mobile or not.
string | $separator | (optional) The separator string used to split the robot name and the version number in the user agent.
boolean | $uaNameFindWords | (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.
[ Top ] ### method androidVerToStr [line 771]
`string androidVerToStr( string $androidVer)`
Convert the Android version numbers to the operating system name. For instance '1.6' returns 'Donut'. #### Tags:
return: | The operating system name or the constant PLATFORM_VERSION_UNKNOWN if nothing match the version numbers.
access: | protected
#### Parameters:
string | $androidVer | The Android version numbers as a string.
[ Top ] ### method checkBrowser [line 1236]
`boolean checkBrowser( )`
Determine what is the browser used by the user. #### Tags:
return: | Returns true if the browser has been identified, false otherwise.
access: | protected
[ Top ] ### method checkBrowserAndroid [line 820]
`boolean checkBrowserAndroid( )`
Determine if the browser is the Android browser (based on the WebKit layout engine and coupled with Chrome's JavaScript engine) or not. #### Tags:
return: | Returns true if the browser is the Android browser, false otherwise.
access: | protected
[ Top ] ### method checkBrowserBlackBerry [line 832]
`boolean checkBrowserBlackBerry( )`
Determine if the browser is the BlackBerry browser or not. #### Tags:
return: | Returns true if the browser is the BlackBerry browser, false otherwise.
link: | https://web.archive.org/web/20170328000854/http://supportforums.blackberry.com/t5/Web-and-WebWorks-Development/How-to-detect-the-BlackBerry-Browser/ta-p/559862
access: | protected
[ Top ] ### method checkBrowserChrome [line 868]
`boolean checkBrowserChrome( )`
Determine if the browser is Chrome or not. #### Tags:
return: | Returns true if the browser is Chrome, false otherwise.
link: | https://www.google.com/chrome/
access: | protected
[ Top ] ### method checkBrowserCustom [line 879]
`boolean checkBrowserCustom( )`
Determine if the browser is among the custom browser rules or not. Rules are checked in the order they were added. #### Tags:
return: | Returns true if we found the browser we were looking for in the custom rules, false otherwise.
access: | protected
[ Top ] ### method checkBrowserEdge [line 898]
`boolean checkBrowserEdge( )`
Determine if the browser is Edge or not. #### Tags:
return: | Returns true if the browser is Edge, false otherwise.
access: | protected
[ Top ] ### method checkBrowserFirebird [line 908]
`boolean checkBrowserFirebird( )`
Determine if the browser is Firebird or not. Firebird was the name of Firefox from version 0.6 to 0.7.1. #### Tags:
return: | Returns true if the browser is Firebird, false otherwise.
access: | protected
[ Top ] ### method checkBrowserFirefox [line 919]
`boolean checkBrowserFirefox( )`
Determine if the browser is Firefox or not. #### Tags:
return: | Returns true if the browser is Firefox, false otherwise.
link: | https://www.mozilla.org/en-US/firefox/new/
access: | protected
[ Top ] ### method checkBrowserIcab [line 941]
`boolean checkBrowserIcab( )`
Determine if the browser is iCab or not. #### Tags:
return: | Returns true if the browser is iCab, false otherwise.
link: | http://www.icab.de/
access: | protected
[ Top ] ### method checkBrowserIceCat [line 953]
`boolean checkBrowserIceCat( )`
Determine if the browser is GNU IceCat (formerly known as GNU IceWeasel) or not. #### Tags:
return: | Returns true if the browser is GNU IceCat, false otherwise.
link: | https://www.gnu.org/software/gnuzilla/
access: | protected
[ Top ] ### method checkBrowserIceWeasel [line 964]
`boolean checkBrowserIceWeasel( )`
Determine if the browser is GNU IceWeasel (now know as GNU IceCat) or not. #### Tags:
return: | Returns true if the browser is GNU IceWeasel, false otherwise.
see: | BrowserDetection::checkBrowserIceCat()
access: | protected
[ Top ] ### method checkBrowserInternetExplorer [line 976]
`boolean checkBrowserInternetExplorer( )`
Determine if the browser is Internet Explorer or not. #### Tags:
return: | Returns true if the browser is Internet Explorer, false otherwise.
link: | https://www.microsoft.com/ie/
link: | https://en.wikipedia.org/wiki/Internet_Explorer_Mobile
access: | protected
[ Top ] ### method checkBrowserKonqueror [line 1067]
`boolean checkBrowserKonqueror( )`
Determine if the browser is Konqueror or not. #### Tags:
return: | Returns true if the browser is Konqueror, false otherwise.
link: | https://www.konqueror.org/
access: | protected
[ Top ] ### method checkBrowserLynx [line 1079]
`boolean checkBrowserLynx( )`
Determine if the browser is Lynx or not. It is the oldest web browser currently in general use and development. It is a text-based only Web browser. #### Tags:
return: | Returns true if the browser is Lynx, false otherwise.
link: | https://en.wikipedia.org/wiki/Lynx_(web_browser)
access: | protected
[ Top ] ### method checkBrowserMozilla [line 1089]
`boolean checkBrowserMozilla( )`
Determine if the browser is Mozilla or not. #### Tags:
return: | Returns true if the browser is Mozilla, false otherwise.
access: | protected
[ Top ] ### method checkBrowserMsnTv [line 1100]
`boolean checkBrowserMsnTv( )`
Determine if the browser is MSN TV (formerly WebTV) or not. #### Tags:
return: | Returns true if the browser is WebTv, false otherwise.
link: | https://en.wikipedia.org/wiki/MSN_TV
access: | protected
[ Top ] ### method checkBrowserNetscape [line 1111]
`boolean checkBrowserNetscape( )`
Determine if the browser is Netscape or not. Official support for this browser ended on March 1st, 2008. #### Tags:
return: | Returns true if the browser is Netscape, false otherwise.
link: | https://en.wikipedia.org/wiki/Netscape
access: | protected
[ Top ] ### method checkBrowserNokia [line 1164]
`boolean checkBrowserNokia( )`
Determine if the browser is a Nokia browser or not. #### Tags:
return: | Returns true if the browser is a Nokia browser, false otherwise.
link: | https://web.archive.org/web/20141012034159/http://www.developer.nokia.com/Community/Wiki/User-Agent_headers_for_Nokia_devices
access: | protected
[ Top ] ### method checkBrowserOpera [line 1190]
`boolean checkBrowserOpera( )`
Determine if the browser is Opera or not. #### Tags:
return: | Returns true if the browser is Opera, false otherwise.
link: | https://web.archive.org/web/20140220123653/http://my.opera.com/community/openweb/idopera/
link: | https://www.opera.com/mobile/
link: | https://www.opera.com/
access: | protected
[ Top ] ### method checkBrowserPhoenix [line 1226]
`boolean checkBrowserPhoenix( )`
Determine if the browser is Phoenix or not. Phoenix was the name of Firefox from version 0.1 to 0.5. #### Tags:
return: | Returns true if the browser is Phoenix, false otherwise.
access: | protected
[ Top ] ### method checkBrowserSafari [line 1278]
`boolean checkBrowserSafari( )`
Determine if the browser is Safari or not. #### Tags:
return: | Returns true if the browser is Safari, false otherwise.
link: | https://en.wikipedia.org/wiki/Safari_version_history#Release_history
link: | https://web.archive.org/web/20080514173941/http://developer.apple.com/internet/safari/uamatrix.html
link: | https://www.apple.com/safari/
access: | protected
[ Top ] ### method checkBrowserSamsung [line 1317]
`boolean checkBrowserSamsung( )`
Determine if the browser is the Samsung Internet browser or not. #### Tags:
return: | Returns true if the browser is the the Samsung Internet browser, false otherwise.
access: | protected
[ Top ] ### method checkBrowserUAWithVersion [line 1336]
`boolean checkBrowserUAWithVersion( mixed $uaNameToLookFor, string $userAgent, string $browserName, [boolean $isMobile = false], [boolean $findWords = true])`
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". #### Tags:
return: | Returns true if we found the browser we were looking for, false otherwise.
access: | protected
#### Parameters:
mixed | $uaNameToLookFor | The string (or array of strings) representing the browser name to find in the user agent.
string | $userAgent | The user agent string to work with.
string | $browserName | The literal browser name. Always use a class constant!
boolean | $isMobile | (optional) Determines if the browser is from a mobile device.
boolean | $findWords | (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.
[ Top ] ### method checkBrowserUC [line 1368]
`boolean checkBrowserUC( )`
Determine if the browser is UC Browser or not. #### Tags:
return: | Returns true if the browser is UC Browser, false otherwise.
access: | protected
[ Top ] ### method checkPlatform [line 1377]
`void checkPlatform( )`
Determine the user's platform. #### Tags:
access: | protected
[ Top ] ### method checkPlatformCustom [line 1447]
`boolean checkPlatformCustom( )`
Determine if the platform is among the custom platform rules or not. Rules are checked in the order they were added. #### Tags:
return: | Returns true if we found the platform we were looking for in the custom rules, false otherwise.
access: | protected
[ Top ] ### method checkPlatformVersion [line 1469]
`void checkPlatformVersion( )`
Determine the user's platform version. #### Tags:
access: | protected
[ Top ] ### method checkRobot [line 1580]
`void checkRobot( )`
Determine if it's a robot crawling the page and find it's name and version. #### Tags:
access: | protected
[ Top ] ### method checkRobotBingbot [line 1542]
`boolean checkRobotBingbot( )`
Determine if the robot is the Bingbot crawler or not. #### Tags:
return: | Returns true if the robot is Bingbot, false otherwise.
link: | https://www.bing.com/webmaster/help/which-crawlers-does-bing-use-8c184ec0
access: | protected
[ Top ] ### method checkRobotCustom [line 1596]
`boolean checkRobotCustom( )`
Determine if the robot is among the custom robot rules or not. Rules are checked in the order they were added. #### Tags:
return: | Returns true if we found the robot we were looking for in the custom rules, false otherwise.
access: | protected
[ Top ] ### method checkRobotGooglebot [line 1552]
`boolean checkRobotGooglebot( )`
Determine if the robot is the Googlebot crawler or not. #### Tags:
return: | Returns true if the robot is Googlebot, false otherwise.
access: | protected
[ Top ] ### method checkRobotMsnBot [line 1571]
`boolean checkRobotMsnBot( )`
Determine if the robot is the MSNBot crawler or not. In October 2010 it was replaced by the Bingbot robot. #### Tags:
return: | Returns true if the robot is MSNBot, false otherwise.
see: | BrowserDetection::checkRobotBingbot()
access: | protected
[ Top ] ### method checkRobotSlurp [line 1616]
`boolean checkRobotSlurp( )`
Determine if the robot is the Yahoo! Slurp crawler or not. #### Tags:
return: | Returns true if the robot is Yahoo! Slurp, false otherwise.
access: | protected
[ Top ] ### method checkRobotW3CValidator [line 1627]
`boolean checkRobotW3CValidator( )`
Determine if the robot is the W3C Validator or not. #### Tags:
return: | Returns true if the robot is the W3C Validator, false otherwise.
link: | https://validator.w3.org/
access: | protected
[ Top ] ### method checkRobotYahooMultimedia [line 1664]
`boolean checkRobotYahooMultimedia( )`
Determine if the robot is the Yahoo! multimedia crawler or not. #### Tags:
return: | Returns true if the robot is the Yahoo! multimedia crawler, false otherwise.
access: | protected
[ Top ] ### method checkSimpleBrowserUA [line 1685]
`boolean checkSimpleBrowserUA( mixed $uaNameToLookFor, string $userAgent, string $browserName, [boolean $isMobile = false], [string $separator = '/'], [boolean $uaNameFindWords = true])`
Test the user agent for a specific browser where the browser name is immediately followed by the version number. The user agent should look like: "Browser name/1.0" or "Browser 1.0;". #### Tags:
return: | Returns true if we found the browser we were looking for, false otherwise.
access: | protected
#### Parameters:
mixed | $uaNameToLookFor | The string (or array of strings) representing the browser name to find in the user agent.
string | $userAgent | The user agent string to work with.
string | $browserName | The literal browser name. Always use a class constant!
boolean | $isMobile | (optional) Determines if the browser is from a mobile device.
string | $separator | (optional) The separator string used to split the browser name and the version number in the user agent.
boolean | $uaNameFindWords | (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.
[ Top ] ### method checkSimpleRobot [line 1714]
`boolean checkSimpleRobot( mixed $uaNameToLookFor, string $userAgent, string $robotName, [string $separator = '/'], [boolean $uaNameFindWords = true])`
Test the user agent for a specific robot where the robot name is immediately followed by the version number. The user agent should look like: "Robot name/1.0" or "Robot 1.0;". #### Tags:
return: | Returns true if we found the robot we were looking for, false otherwise.
access: | protected
#### Parameters:
mixed | $uaNameToLookFor | The string (or array of strings) representing the robot name to find in the user agent.
string | $userAgent | The user agent string to work with.
string | $robotName | The literal robot name. Always use a class constant!
string | $separator | (optional) The separator string used to split the robot name and the version number in the user agent.
boolean | $uaNameFindWords | (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.
[ Top ] ### method cleanVersion [line 1734]
`string cleanVersion( string $version, [mixed $toRemove = NULL])`
Clean a version string from unwanted characters. #### Tags:
return: | Returns the cleaned version number string.
access: | protected
#### Parameters:
string | $version | The version string to clean.
mixed | $toRemove | (optional) String or array of strings representing additional string(s) to remove.
[ Top ] ### method compareVersions [line 467]
`int compareVersions( string $sourceVer, string $compareVer)`
Compare two version number strings. #### Tags:
return: | Returns -1 if $sourceVer < $compareVer, 0 if $sourceVer == $compareVer or 1 if $sourceVer > $compareVer.
access: | public
#### Parameters:
string | $sourceVer | The source version number.
string | $compareVer | The version number to compare with the source version number.
[ Top ] ### method containString [line 1782]
`boolean containString( string $haystack, mixed $needle, [boolean $insensitive = true], [boolean $findWords = true], [ &$foundPos = NULL], int $foundPos)`
Find if one or more substring is contained in a string. #### Tags:
return: | Returns true if the needle (or one of the needles) has been found in the haystack, false otherwise.
access: | protected
#### Parameters:
string | $haystack | The string to search in.
mixed | $needle | The string to search for. Can be a string or an array of strings if multiples values are to be searched.
boolean | $insensitive | (optional) Determines if we do a case-sensitive search (false) or a case-insensitive one (true).
boolean | $findWords | (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.
int | $foundPos | (optional) Integer buffer that will contain the position of the needle (if found and if a non NULL variable has been passed).
| &$foundPos |
[ Top ] ### method detect [line 1814]
`void detect( )`
Detect the user environment from the details in the user agent string. #### Tags:
access: | protected
[ Top ] ### method findAndGetVersion [line 1835]
`boolean findAndGetVersion( type $uaNameToLookFor, type $userAgent, &$version, [type $separator = '/'], [type $uaNameFindWords = true], type $version)`
Test the user agent for a specific browser and extract it's version. #### Tags:
return: | Returns true if we found the browser we were looking for, false otherwise.
access: | protected
#### Parameters:
type | $uaNameToLookFor | The string (or array of strings) representing the browser name to find in the user agent.
type | $userAgent | The user agent string to work with.
type | $version | String buffer that will contain the version found (if any).
type | $separator | (optional) The separator string used to split the browser name and the version number in the user agent.
type | $uaNameFindWords | (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.
| &$version |
[ Top ] ### method getIECompatibilityView [line 514]
`mixed getIECompatibilityView( [boolean $asArray = false])`
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. #### Tags:
return: | 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.
access: | public
#### Parameters:
boolean | $asArray | (optional) Determines if the return value must be an array (true) or a string (false).
[ Top ] ### method getLibVersion [line 527]
`string getLibVersion( )`
Return the BrowserDetection class version. #### Tags:
return: | Returns the version as a sting with the #.#.# format.
access: | public
[ Top ] ### method getName [line 537]
`string 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. #### Tags:
return: | Returns the name of the browser or BrowserDetection::BROWSER_UNKNOWN if unknown.
access: | public
[ Top ] ### method getPlatform [line 548]
`string 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. #### Tags:
return: | Returns the name of the platform or BrowserDetection::PLATFORM_UNKNOWN if unknown.
access: | public
[ Top ] ### method getPlatformVersion [line 566]
`string getPlatformVersion( [boolean $returnVersionNumbers = false], [boolean $returnServerFlavor = false])`
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. #### Tags:
return: | Returns the version name/version numbers of the platform or the constant PLATFORM_VERSION_UNKNOWN if unknown.
access: | public
#### Parameters:
boolean | $returnVersionNumbers | (optional) Determines if the return value must be versions numbers as a string (true) or the version name (false).
boolean | $returnServerFlavor | (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.
[ Top ] ### method getRobotName [line 603]
`string 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. #### Tags:
return: | Returns the name of the robot or BrowserDetection::ROBOT_UNKNOWN if unknown.
access: | public
[ Top ] ### method getRobotVersion [line 612]
`string getRobotVersion( )`
Get the version of the robot. #### Tags:
return: | Returns the version of the robot or BrowserDetection::ROBOT_VERSION_UNKNOWN if unknown.
access: | public
[ Top ] ### method getUserAgent [line 621]
`string getUserAgent( )`
Get the user agent value used by the class to determine the browser details. #### Tags:
return: | The user agent string.
access: | public
[ Top ] ### method getVersion [line 630]
`string getVersion( )`
Get the version of the browser. #### Tags:
return: | Returns the version of the browser or BrowserDetection::VERSION_UNKNOWN if unknown.
access: | public
[ Top ] ### method iOSVerToStr [line 1869]
`string iOSVerToStr( string $iOSVer)`
Convert the iOS version numbers to the operating system name. For instance '2.0' returns 'iPhone OS 2.0'. #### Tags:
return: | The operating system name.
access: | protected
#### Parameters:
string | $iOSVer | The iOS version numbers as a string.
[ Top ] ### method is64bitPlatform [line 640]
`boolean 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. #### Tags:
return: | Returns true if the browser is executed from a 64-bit platform.
access: | public
[ Top ] ### method isChromeFrame [line 650]
`boolean 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). #### Tags:
return: | Returns true if the browser is using Google Chrome Frame, false otherwise.
access: | public
[ Top ] ### method isInIECompatibilityView [line 661]
`boolean 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. #### Tags:
return: | Returns true if the browser is in compatibility view, false otherwise.
access: | public
[ Top ] ### method isMobile [line 670]
`boolean isMobile( )`
Determine if the browser is from a mobile device or not. #### Tags:
return: | Returns true if the browser is from a mobile device, false otherwise.
access: | public
[ Top ] ### method isRobot [line 679]
`boolean isRobot( )`
Determine if the browser is a robot (Googlebot, Bingbot, Yahoo! Slurp...) or not. #### Tags:
return: | Returns true if the browser is a robot, false otherwise.
access: | public
[ Top ] ### method macVerToStr [line 1885]
`string macVerToStr( string $macVer)`
Convert the macOS version numbers to the operating system name. For instance '10.7' returns 'Mac OS X Lion'. #### Tags:
return: | The operating system name or the constant PLATFORM_VERSION_UNKNOWN if nothing match the version numbers.
access: | protected
#### Parameters:
string | $macVer | The macOS version numbers as a string.
[ Top ] ### method parseInt [line 1938]
`int parseInt( string $intStr)`
Get the integer value of a string variable. #### Tags:
return: | The integer value of $intStr on success, or 0 on failure.
access: | protected
#### Parameters:
string | $intStr | The scalar value being converted to an integer.
[ Top ] ### method removeCustomBrowserDetection [line 690]
`boolean removeCustomBrowserDetection( string $browserName)`
Remove support for a previously added Web browser. #### Tags:
return: | Returns true if the custom rule has been found and removed, false otherwise.
see: | BrowserDetection::addCustomBrowserDetection()
access: | public
#### Parameters:
string | $browserName | The Web browser name as used when added.
[ Top ] ### method removeCustomPlatformDetection [line 706]
`boolean removeCustomPlatformDetection( string $platformName)`
Remove support for a previously added platform. #### Tags:
return: | Returns true if the custom rule has been found and removed, false otherwise.
see: | BrowserDetection::addCustomPlatformDetection()
access: | public
#### Parameters:
string | $platformName | The platform name as used when added.
[ Top ] ### method removeCustomRobotDetection [line 722]
`boolean removeCustomRobotDetection( string $robotName)`
Remove support for a previously added robot. #### Tags:
return: | Returns true if the custom rule has been found and removed, false otherwise.
see: | BrowserDetection::addCustomRobotDetection()
access: | public
#### Parameters:
string | $robotName | The robot name as used when added.
[ Top ] ### method reset [line 1947]
`void reset( )`
Reset all the properties of the class. #### Tags:
access: | protected
[ Top ] ### method safariBuildToSafariVer [line 1971]
`string safariBuildToSafariVer( string $version)`
Convert a Safari build number to a Safari version number. #### Tags:
return: | Returns the Safari version string. If the version can't be determined, an empty string is returned.
link: | https://web.archive.org/web/20080514173941/http://developer.apple.com/internet/safari/uamatrix.html
access: | protected
#### Parameters:
string | $version | A string representing the version number.
[ Top ] ### method set64bit [line 2065]
`void set64bit( boolean $is64bit)`
Set if the browser is executed from a 64-bit platform. #### Tags:
access: | protected
#### Parameters:
boolean | $is64bit | Value that tells if the browser is executed from a 64-bit platform.
[ Top ] ### method setBrowser [line 2075]
`void setBrowser( string $browserName)`
Set the name of the browser. #### Tags:
access: | protected
#### Parameters:
string | $browserName | The name of the browser.
[ Top ] ### method setMobile [line 2085]
`void setMobile( [boolean $isMobile = true])`
Set the browser to be from a mobile device or not. #### Tags:
access: | protected
#### Parameters:
boolean | $isMobile | (optional) Value that tells if the browser is on a mobile device or not.
[ Top ] ### method setPlatform [line 2095]
`void setPlatform( string $platform)`
Set the platform on which the browser is on. #### Tags:
access: | protected
#### Parameters:
string | $platform | The name of the platform.
[ Top ] ### method setPlatformVersion [line 2105]
`void setPlatformVersion( string $platformVer)`
Set the platform version on which the browser is on. #### Tags:
access: | protected
#### Parameters:
string | $platformVer | The version numbers of the platform.
[ Top ] ### method setRobot [line 2115]
`void setRobot( [boolean $isRobot = true])`
Set the browser to be a robot (crawler) or not. #### Tags:
access: | protected
#### Parameters:
boolean | $isRobot | (optional) Value that tells if the browser is a robot or not.
[ Top ] ### method setRobotName [line 2125]
`void setRobotName( string $robotName)`
Set the name of the robot. #### Tags:
access: | protected
#### Parameters:
string | $robotName | The name of the robot.
[ Top ] ### method setRobotVersion [line 2135]
`void setRobotVersion( string $robotVersion)`
Set the version of the robot. #### Tags:
access: | protected
#### Parameters:
string | $robotVersion | The version of the robot.
[ Top ] ### method setUserAgent [line 737]
`void setUserAgent( [string $agentString = ''])`
Set the user agent to use with the class. #### Tags:
access: | public
#### Parameters:
string | $agentString | (optional) The value of the user agent. If an empty string is sent (default), $_SERVER['HTTP_USER_AGENT'] will be used.
[ Top ] ### method setVersion [line 2151]
`void setVersion( string $version)`
Set the version of the browser. #### Tags:
access: | protected
#### Parameters:
string | $version | The version of the browser.
[ Top ] ### method webKitBuildToSafariVer [line 2170]
`string webKitBuildToSafariVer( string $version)`
Convert a WebKit build number to a Safari version number. #### Tags:
return: | Returns the Safari version string. If the version can't be determined, an empty string is returned.
link: | https://web.archive.org/web/20080514173941/http://developer.apple.com/internet/safari/uamatrix.html
access: | protected
#### Parameters:
string | $version | A string representing the version number.
[ Top ] ### method windowsNTVerToStr [line 2279]
`string windowsNTVerToStr( string $winVer, [boolean $returnServerFlavor = false])`
Convert the Windows NT family version numbers to the operating system name. For instance '5.1' returns 'Windows XP'. #### Tags:
return: | The operating system name or the constant PLATFORM_VERSION_UNKNOWN if nothing match the version numbers.
access: | protected
#### Parameters:
string | $winVer | The Windows NT family version numbers as a string.
boolean | $returnServerFlavor | (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.
[ Top ] ### method windowsVerToStr [line 2325]
`string windowsVerToStr( string $winVer)`
Convert the Windows 3.x & 9x family version numbers to the operating system name. For instance '4.10.1998' returns 'Windows 98'. #### Tags:
return: | The operating system name or the constant PLATFORM_VERSION_UNKNOWN if nothing match the version numbers.
access: | protected
#### Parameters:
string | $winVer | The Windows 3.x or 9x family version numbers as a string.
[ Top ] ### method wordPos [line 2359]
`mixed wordPos( string $haystack, string $needle, [boolean $insensitive = true], [int $offset = 0], [ &$foundString = NULL], string $foundString)`
Find the position of the first occurrence of a word in a string. #### Tags:
return: | 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.
access: | protected
#### Parameters:
string | $haystack | The string to search in.
string | $needle | The string to search for.
boolean | $insensitive | (optional) Determines if we do a case-sensitive search (false) or a case-insensitive one (true).
int | $offset | 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.
string | $foundString | String buffer that will contain the exact matching needle found. Set to NULL when return value of the function is false.
| &$foundString |
[ Top ] ### method __toString [line 341]
`string __toString( )`
Determine how the class will react when it is treated like a string. #### Tags:
return: | Returns an HTML formatted string with a summary of the browser informations.
access: | public
[ Top ] ### Class Constants #### BROWSER_ANDROID = 'Android' [line 164] Constant for the name of the Web browser. [ Top ] #### BROWSER_BLACKBERRY = 'BlackBerry' [line 165] Constant for the name of the Web browser. [ Top ] #### BROWSER_CHROME = 'Chrome' [line 166] Constant for the name of the Web browser. [ Top ] #### BROWSER_EDGE = 'Edge' [line 167] Constant for the name of the Web browser. [ Top ] #### BROWSER_FIREBIRD = 'Firebird' [line 168] Constant for the name of the Web browser. [ Top ] #### BROWSER_FIREFOX = 'Firefox' [line 169] Constant for the name of the Web browser. [ Top ] #### BROWSER_ICAB = 'iCab' [line 170] Constant for the name of the Web browser. [ Top ] #### BROWSER_ICECAT = 'GNU IceCat' [line 171] Constant for the name of the Web browser. [ Top ] #### BROWSER_ICEWEASEL = 'GNU IceWeasel' [line 172] Constant for the name of the Web browser. [ Top ] #### BROWSER_IE = 'Internet Explorer' [line 173] Constant for the name of the Web browser. [ Top ] #### BROWSER_IE_MOBILE = 'Internet Explorer Mobile' [line 174] Constant for the name of the Web browser. [ Top ] #### BROWSER_KONQUEROR = 'Konqueror' [line 175] Constant for the name of the Web browser. [ Top ] #### BROWSER_LYNX = 'Lynx' [line 176] Constant for the name of the Web browser. [ Top ] #### BROWSER_MOZILLA = 'Mozilla' [line 177] Constant for the name of the Web browser. [ Top ] #### BROWSER_MSNTV = 'MSN TV' [line 178] Constant for the name of the Web browser. [ Top ] #### BROWSER_NETSCAPE = 'Netscape' [line 179] Constant for the name of the Web browser. [ Top ] #### BROWSER_NOKIA = 'Nokia Browser' [line 180] Constant for the name of the Web browser. [ Top ] #### BROWSER_OPERA = 'Opera' [line 181] Constant for the name of the Web browser. [ Top ] #### BROWSER_OPERA_MINI = 'Opera Mini' [line 182] Constant for the name of the Web browser. [ Top ] #### BROWSER_OPERA_MOBILE = 'Opera Mobile' [line 183] Constant for the name of the Web browser. [ Top ] #### BROWSER_PHOENIX = 'Phoenix' [line 184] Constant for the name of the Web browser. [ Top ] #### BROWSER_SAFARI = 'Safari' [line 185] Constant for the name of the Web browser. [ Top ] #### BROWSER_SAMSUNG = 'Samsung Internet' [line 186] Constant for the name of the Web browser. [ Top ] #### BROWSER_TABLET_OS = 'BlackBerry Tablet OS' [line 187] Constant for the name of the Web browser. [ Top ] #### BROWSER_UC = 'UC Browser' [line 188] Constant for the name of the Web browser. [ Top ] #### BROWSER_UNKNOWN = 'unknown' [line 189] Constant for the name of the Web browser. [ Top ] #### PLATFORM_ANDROID = 'Android' [line 195] Constant for the name of the platform on which the Web browser runs. [ Top ] #### PLATFORM_BLACKBERRY = 'BlackBerry' [line 196] Constant for the name of the platform on which the Web browser runs. [ Top ] #### PLATFORM_CHROME_OS = 'Chrome OS' [line 197] Constant for the name of the platform on which the Web browser runs. [ Top ] #### PLATFORM_FREEBSD = 'FreeBSD' [line 198] Constant for the name of the platform on which the Web browser runs. [ Top ] #### PLATFORM_IOS = 'iOS' [line 199] Constant for the name of the platform on which the Web browser runs. [ Top ] #### PLATFORM_LINUX = 'Linux' [line 200] Constant for the name of the platform on which the Web browser runs. [ Top ] #### PLATFORM_MACINTOSH = 'Macintosh' [line 201] Constant for the name of the platform on which the Web browser runs. [ Top ] #### PLATFORM_NETBSD = 'NetBSD' [line 202] Constant for the name of the platform on which the Web browser runs. [ Top ] #### PLATFORM_NOKIA = 'Nokia' [line 203] Constant for the name of the platform on which the Web browser runs. [ Top ] #### PLATFORM_OPENBSD = 'OpenBSD' [line 204] Constant for the name of the platform on which the Web browser runs. [ Top ] #### PLATFORM_OPENSOLARIS = 'OpenSolaris' [line 205] Constant for the name of the platform on which the Web browser runs. [ Top ] #### PLATFORM_SYMBIAN = 'Symbian' [line 206] Constant for the name of the platform on which the Web browser runs. [ Top ] #### PLATFORM_UNKNOWN = 'unknown' [line 207] Constant for the name of the platform on which the Web browser runs. [ Top ] #### PLATFORM_VERSION_UNKNOWN = 'unknown' [line 208] Constant for the name of the platform on which the Web browser runs. [ Top ] #### PLATFORM_WINDOWS = 'Windows' [line 209] Constant for the name of the platform on which the Web browser runs. [ Top ] #### PLATFORM_WINDOWS_CE = 'Windows CE' [line 210] Constant for the name of the platform on which the Web browser runs. [ Top ] #### PLATFORM_WINDOWS_PHONE = 'Windows Phone' [line 211] Constant for the name of the platform on which the Web browser runs. [ Top ] #### ROBOT_BINGBOT = 'Bingbot' [line 217] Constant for the name of the robot. [ Top ] #### ROBOT_GOOGLEBOT = 'Googlebot' [line 218] Constant for the name of the robot. [ Top ] #### ROBOT_MSNBOT = 'MSNBot' [line 219] Constant for the name of the robot. [ Top ] #### ROBOT_SLURP = 'Yahoo! Slurp' [line 220] Constant for the name of the robot. [ Top ] #### ROBOT_UNKNOWN = '' [line 221] Constant for the name of the robot. [ Top ] #### ROBOT_VERSION_UNKNOWN = '' [line 222] Constant for the name of the robot. [ Top ] #### ROBOT_W3CVALIDATOR = 'W3C Validator' [line 223] Constant for the name of the robot. [ Top ] #### ROBOT_YAHOO_MM = 'Yahoo! Multimedia' [line 224] Constant for the name of the robot. [ Top ] #### VERSION_UNKNOWN = 'unknown' [line 230] Version unknown constant. [ Top ] Documentation generated on Tue, 20 Sep 2022 23:35:16 -0400 by phpDocumentor 1.4.3