DETECTION_TYPE_MOBILE
DETECTION_TYPE_MOBILE
Mobile detection type.
None found |
None found |
VERSION_TYPE_STRING
A type for the version() method indicating a string return value.
None found |
VERSION_TYPE_FLOAT
A type for the version() method indicating a float return value.
None found |
None found |
$httpHeaders : array
HTTP headers in the PHP-flavor. So HTTP_USER_AGENT and SERVER_SOFTWARE.
None found |
None found |
$matchesArray : string
The matches extracted from the regex expression.
This is good for debug.
None found |
$detectionType : string
The detection type, using self::DETECTION_TYPE_MOBILE or self::DETECTION_TYPE_EXTENDED.
None found |
$mobileHeaders : array
HTTP headers that trigger the 'isMobile' detection to be true.
None found |
None found |
$uaHttpHeaders : array
All possible HTTP headers that represent the User-Agent string.
None found |
$properties : array
The individual segments that could exist in a User-Agent string. VER refers to the regular expression defined in the constant self::VER.
None found |
__construct(array $headers = null, string $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. |
None found |
getScriptVersion() : string
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.
The version number in semantic version format.
None found |
setHttpHeaders(array $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 compatibilty. |
None found |
getHttpHeader(string $header) : string|null
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. |
The value of the header.
None found |
getUaHttpHeaders() : array
Get all possible HTTP headers that can contain the User-Agent string.
List of HTTP headers.
None found |
setUserAgent(string $userAgent = null) : string|null
Set the User-Agent to be used.
string | $userAgent | The user agent string to set. |
None found |
getUserAgent() : string|null
Retrieve the User-Agent.
The user agent if it's set.
None found |
setDetectionType(string $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::DETECTIONTYPE* constant. The default parameter is null which will default to self::DETECTION_TYPE_MOBILE. |
None found |
getPhoneDevices() : array
Retrieve the list of known phone devices.
List of phone devices.
None found |
getTabletDevices() : array
Retrieve the list of known tablet devices.
List of tablet devices.
None found |
getUserAgents() : array
Alias for getBrowsers() method.
List of user agents.
None found |
getBrowsers() : array
Retrieve the list of known browsers. Specifically, the user agents.
List of browsers / user agents.
None found |
getUtilities() : array
Retrieve the list of known utilities.
List of utilities.
None found |
getMobileDetectionRules() : array
Method gets the mobile detection rules. This method is used for the magic methods $detect->is*().
All the rules (but not extended).
None found |
getMobileDetectionRulesExtended() : array
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.
All the rules + extended.
None found |
None found |
getOperatingSystems() : array
Retrieve the list of mobile operating systems.
The list of mobile operating systems.
None found |
checkHttpHeadersForMobile() : boolean
Check the HTTP headers for signs of mobile.
This is the fastest mobile check possible; it's used inside isMobile() method.
None found |
__call(string $name, array $arguments) : mixed
Magic overloading method.
string | $name | |
array | $arguments |
when the method doesn't exist and doesn't start with 'is'
method |
boolean is[...]() |
---|
isMobile(null $userAgent = null, null $httpHeaders = null) : boolean
Check if the device is mobile.
Returns true if any type of mobile device detected, including special ones
null | $userAgent | deprecated |
null | $httpHeaders | deprecated |
None found |
isTablet(string $userAgent = null, array $httpHeaders = null) : boolean
Check if the device is a tablet.
Return true if any type of tablet device is detected.
string | $userAgent | deprecated |
array | $httpHeaders | deprecated |
None found |
is(string $key, string $userAgent = null, string $httpHeaders = null) : boolean|integer|null
This method checks for a certain property in the userAgent.
string | $key | |
string | $userAgent | deprecated |
string | $httpHeaders | deprecated |
todo |
: The httpHeaders part is not yet used. |
---|
match( $regex, string $userAgent = null) : boolean
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 |
todo |
: search in the HTTP headers too. |
---|
None found |
prepareVersionNo(string $ver) : float
Prepare the version number.
string | $ver | The string version, like "2.6.21.2152"; |
todo |
Remove the error supression from str_replace() call. |
---|
version(string $propertyName, string $type = self::VERSION_TYPE_STRING) : string|float
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. |
The version of the property we are trying to extract.
None found |
mobileGrade() : string
Retrieve the mobile grading, using self::MOBILE_GRADE_* constants.
One of the self::MOBILEGRADE* constants.
None found |