|
Odyssey
|
Public Member Functions | |
| __construct (array $headers=null, $userAgent=null) | |
| setHttpHeaders ($httpHeaders=null) | |
| getHttpHeaders () | |
| getHttpHeader ($header) | |
| getMobileHeaders () | |
| getUaHttpHeaders () | |
| setCfHeaders ($cfHeaders=null) | |
| getCfHeaders () | |
| setUserAgent ($userAgent=null) | |
| getUserAgent () | |
| setDetectionType ($type=null) | |
| getMatchingRegex () | |
| getMatchesArray () | |
| getMobileDetectionRulesExtended () | |
| getRules () | |
| checkHttpHeadersForMobile () | |
| __call ($name, $arguments) | |
| isMobile ($userAgent=null, $httpHeaders=null) | |
| isTablet ($userAgent=null, $httpHeaders=null) | |
| is ($key, $userAgent=null, $httpHeaders=null) | |
| match ($regex, $userAgent=null) | |
| prepareVersionNo ($ver) | |
| version ($propertyName, $type=self::VERSION_TYPE_STRING) | |
| mobileGrade () | |
Static Public Member Functions | |
| static | getScriptVersion () |
| static | getPhoneDevices () |
| static | getTabletDevices () |
| static | getUserAgents () |
| static | getBrowsers () |
| static | getUtilities () |
| static | getMobileDetectionRules () |
| static | getOperatingSystems () |
| static | getProperties () |
Public Attributes | |
| const | DETECTION_TYPE_MOBILE = 'mobile' |
| const | DETECTION_TYPE_EXTENDED = 'extended' |
| const | VER = '([\w._\+]+)' |
| const | MOBILE_GRADE_A = 'A' |
| const | MOBILE_GRADE_B = 'B' |
| const | MOBILE_GRADE_C = 'C' |
| const | VERSION = '2.8.33' |
| const | VERSION_TYPE_STRING = 'text' |
| const | VERSION_TYPE_FLOAT = 'float' |
Protected Member Functions | |
| matchDetectionRulesAgainstUA ($userAgent=null) | |
| matchUAAgainstKey ($key) | |
Protected Attributes | |
| $cache = array() | |
| $userAgent = null | |
| $httpHeaders = array() | |
| $cloudfrontHeaders = array() | |
| $matchingRegex = null | |
| $matchesArray = null | |
| $detectionType = self::DETECTION_TYPE_MOBILE | |
Static Protected Attributes | |
| static | $mobileHeaders |
| static | $phoneDevices |
| static | $tabletDevices |
| static | $operatingSystems |
| static | $browsers |
| static | $utilities |
| static | $uaHttpHeaders |
| static | $properties |
Private Member Functions | |
| prepareUserAgent ($userAgent) | |
Mobile Detect Library Motto: "Every business should have a mobile detection script to detect mobile readers"
Mobile_Detect is a lightweight PHP class for detecting mobile devices (including tablets). It uses the User-Agent string combined with specific HTTP headers to detect the mobile environment.
Homepage: http://mobiledetect.net GitHub: https://github.com/serbanghita/Mobile-Detect README: https://github.com/serbanghita/Mobile-Detect/blob/master/README.md CONTRIBUTING: https://github.com/serbanghita/Mobile-Detect/blob/master/docs/CONTRIBUTING.md KNOWN LIMITATIONS: https://github.com/serbanghita/Mobile-Detect/blob/master/docs/KNOWN_LIMITATIONS.md EXAMPLES: https://github.com/serbanghita/Mobile-Detect/wiki/Code-examples
@license https://github.com/serbanghita/Mobile-Detect/blob/master/LICENSE.txt MIT License
Definition at line 23 of file Mobile_Detect.php.
| Mobile_Detect::__construct | ( | array | $headers = null, |
$userAgent = null |
|||
| ) |
Construct an instance of this class.
| array | $headers | Specify the headers as injection. Should be PHP SERVER flavored. If left empty, will use the global _SERVER['HTTP*'] vars instead. |
| string | $userAgent | Inject the User-Agent header. If null, will use HTTP_USER_AGENT from the $headers array instead. |
Definition at line 680 of file Mobile_Detect.php.
| Mobile_Detect::__call | ( | $name, | |
| $arguments | |||
| ) |
Magic overloading method.
@method boolean is[...]()
| string | $name | |
| array | $arguments |
| BadMethodCallException | when the method doesn't exist and doesn't start with 'is' |
Definition at line 1079 of file Mobile_Detect.php.
| Mobile_Detect::checkHttpHeadersForMobile | ( | ) |
Check the HTTP headers for signs of mobile. This is the fastest mobile check possible; it's used inside isMobile() method.
Definition at line 1047 of file Mobile_Detect.php.
|
static |
Retrieve the list of known browsers. Specifically, the user agents.
Definition at line 947 of file Mobile_Detect.php.
| Mobile_Detect::getCfHeaders | ( | ) |
| Mobile_Detect::getHttpHeader | ( | $header | ) |
Retrieves a particular header. If it doesn't exist, no exception/error is caused. Simply null is returned.
| string | $header | The name of the header to retrieve. Can be HTTP compliant such as "User-Agent" or "X-Device-User-Agent" or can be php-esque with the all-caps, HTTP_ prefixed, underscore seperated awesomeness. |
Definition at line 749 of file Mobile_Detect.php.
| Mobile_Detect::getHttpHeaders | ( | ) |
|
static |
Method gets the mobile detection rules. This method is used for the magic methods $detect->is*().
Definition at line 969 of file Mobile_Detect.php.
| Mobile_Detect::getMobileDetectionRulesExtended | ( | ) |
Method gets the mobile detection rules + utilities. The reason this is separate is because utilities rules don't necessary imply mobile. This method is used inside the new $detect->is('stuff') method.
Definition at line 996 of file Mobile_Detect.php.
|
static |
Retrieve the list of mobile operating systems.
Definition at line 1035 of file Mobile_Detect.php.
|
static |
Retrieve the list of known phone devices.
Definition at line 917 of file Mobile_Detect.php.
|
static |
| Mobile_Detect::getRules | ( | ) |
Retrieve the current set of rules.
Definition at line 1021 of file Mobile_Detect.php.
|
static |
Get the current script version. This is useful for the demo.php file, so people can check on what version they are testing for mobile devices.
Definition at line 696 of file Mobile_Detect.php.
|
static |
Retrieve the list of known tablet devices.
Definition at line 927 of file Mobile_Detect.php.
| Mobile_Detect::getUaHttpHeaders | ( | ) |
Get all possible HTTP headers that can contain the User-Agent string.
Definition at line 781 of file Mobile_Detect.php.
| Mobile_Detect::getUserAgent | ( | ) |
Retrieve the User-Agent.
Definition at line 875 of file Mobile_Detect.php.
|
static |
Alias for getBrowsers() method.
Definition at line 937 of file Mobile_Detect.php.
|
static |
Retrieve the list of known utilities.
Definition at line 957 of file Mobile_Detect.php.
| Mobile_Detect::is | ( | $key, | |
$userAgent = null, |
|||
$httpHeaders = null |
|||
| ) |
This method checks for a certain property in the userAgent.
| string | $key | |
| string | $userAgent | deprecated |
| string | $httpHeaders | deprecated |
Definition at line 1220 of file Mobile_Detect.php.
| Mobile_Detect::isMobile | ( | $userAgent = null, |
|
$httpHeaders = null |
|||
| ) |
Check if the device is mobile. Returns true if any type of mobile device detected, including special ones
| null | $userAgent | deprecated |
| null | $httpHeaders | deprecated |
Definition at line 1152 of file Mobile_Detect.php.
| Mobile_Detect::isTablet | ( | $userAgent = null, |
|
$httpHeaders = null |
|||
| ) |
Check if the device is a tablet. Return true if any type of tablet device is detected.
| string | $userAgent | deprecated |
| array | $httpHeaders | deprecated |
Definition at line 1189 of file Mobile_Detect.php.
| Mobile_Detect::match | ( | $regex, | |
$userAgent = null |
|||
| ) |
Some detection rules are relative (not standard), because of the diversity of devices, vendors and their conventions in representing the User-Agent or the HTTP headers.
This method will be used to check custom regexes against the User-Agent string.
| $regex | ||
| string | $userAgent |
Definition at line 1251 of file Mobile_Detect.php.
|
protected |
Find a detection rule that matches the current User-agent.
| null | $userAgent | deprecated |
Definition at line 1099 of file Mobile_Detect.php.
|
protected |
Search for a certain key in the rules array. If the key is found then try to match the corresponding regex against the User-Agent.
| string | $key |
Definition at line 1124 of file Mobile_Detect.php.
| Mobile_Detect::mobileGrade | ( | ) |
Retrieve the mobile grading, using self::MOBILE_GRADE_* constants.
Definition at line 1352 of file Mobile_Detect.php.
|
private |
| Mobile_Detect::prepareVersionNo | ( | $ver | ) |
Prepare the version number.
| string | $ver | The string version, like "2.6.21.2152"; |
Definition at line 1282 of file Mobile_Detect.php.
| Mobile_Detect::setCfHeaders | ( | $cfHeaders = null | ) |
Set CloudFront headers http://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/header-caching.html#header-caching-web-device
| array | $cfHeaders | List of HTTP headers |
Definition at line 795 of file Mobile_Detect.php.
| Mobile_Detect::setDetectionType | ( | $type = null | ) |
Set the detection type. Must be one of self::DETECTION_TYPE_MOBILE or self::DETECTION_TYPE_EXTENDED. Otherwise, nothing is set.
| string | $type | The type. Must be a self::DETECTION_TYPE_* constant. The default parameter is null which will default to self::DETECTION_TYPE_MOBILE. |
Definition at line 889 of file Mobile_Detect.php.
| Mobile_Detect::setHttpHeaders | ( | $httpHeaders = null | ) |
Set the HTTP Headers. Must be PHP-flavored. This method will reset existing headers.
| array | $httpHeaders | The headers to set. If null, then using PHP's _SERVER to extract the headers. The default null is left for backwards compatibility. |
Definition at line 707 of file Mobile_Detect.php.
| Mobile_Detect::setUserAgent | ( | $userAgent = null | ) |
Set the User-Agent to be used.
| string | $userAgent | The user agent string to set. |
Definition at line 844 of file Mobile_Detect.php.
| Mobile_Detect::version | ( | $propertyName, | |
$type = self::VERSION_TYPE_STRING |
|||
| ) |
Check the version of the given property in the User-Agent. Will return a float number. (eg. 2_0 will return 2.0, 4.3.1 will return 4.31)
| string | $propertyName | The name of the property. See self::getProperties() array keys for all possible properties. |
| string | $type | Either self::VERSION_TYPE_STRING to get a string value or self::VERSION_TYPE_FLOAT indicating a float value. This parameter is optional and defaults to self::VERSION_TYPE_STRING. Passing an invalid parameter will default to the this type as well. |
Definition at line 1307 of file Mobile_Detect.php.
|
staticprotected |
Definition at line 130 of file Mobile_Detect.php.
|
staticprotected |
Definition at line 481 of file Mobile_Detect.php.
|
staticprotected |
Definition at line 582 of file Mobile_Detect.php.
|
staticprotected |
Definition at line 561 of file Mobile_Detect.php.
| const Mobile_Detect::DETECTION_TYPE_EXTENDED = 'extended' |
Extended detection type.
Definition at line 37 of file Mobile_Detect.php.
| const Mobile_Detect::DETECTION_TYPE_MOBILE = 'mobile' |
Mobile detection type.
Definition at line 30 of file Mobile_Detect.php.
| const Mobile_Detect::MOBILE_GRADE_A = 'A' |
Top-level device.
Definition at line 49 of file Mobile_Detect.php.
| const Mobile_Detect::MOBILE_GRADE_B = 'B' |
Mid-level device.
Definition at line 54 of file Mobile_Detect.php.
| const Mobile_Detect::MOBILE_GRADE_C = 'C' |
Low-level device.
Definition at line 59 of file Mobile_Detect.php.
| const Mobile_Detect::VER = '([\w._\+]+)' |
A frequently used regular expression to extract version #s.
Definition at line 44 of file Mobile_Detect.php.
| const Mobile_Detect::VERSION = '2.8.33' |
Stores the version number of the current release.
Definition at line 64 of file Mobile_Detect.php.
| const Mobile_Detect::VERSION_TYPE_FLOAT = 'float' |
A type for the version() method indicating a float return value.
Definition at line 74 of file Mobile_Detect.php.
| const Mobile_Detect::VERSION_TYPE_STRING = 'text' |
A type for the version() method indicating a string return value.
Definition at line 69 of file Mobile_Detect.php.
1.8.15